public async Task SelectTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; using var app = await TestWpfApp.CreateAsync(cancellationToken); await using var hookService = new HookService { new (new Command("select"), ConsoleKey.S, isProcessing : true), }; await using var moduleService = new StaticModuleService( new SelectRunner(app.Dispatcher) ); await using var runnerService = new RunnerService( moduleService, moduleService, hookService ); using var exceptions = new IServiceBase[] { moduleService, runnerService, hookService }.EnableLogging(cancellationTokenSource); await hookService.InitializeAsync(cancellationToken); await Task.Delay(TimeSpan.FromSeconds(15), cancellationToken); await runnerService.WaitAllAsync(cancellationToken); }
public async Task TelegramRecordedAudioTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateDefaultRecorder(), TestModules.CreateTelegramRunner() ); await using var runnerService = new RunnerService(moduleService); await using var recognitionService = new RecognitionService(moduleService); using var exceptions = new IServiceBase[] { moduleService, runnerService }.EnableLogging(cancellationTokenSource); var bytes = await recognitionService.StartRecordMp3_5Second_Stop_Async(cancellationToken); await runnerService.RunAsync( new Command("telegram audio", new Value(string.Empty, nameof(TelegramRecordedAudioTest)) { Data = bytes, }), cancellationToken); }
public async Task ProcessTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var hookService = new HookService { new (new Command("process-job"), ConsoleKey.K, isProcessing : true), }; await using var moduleService = new StaticModuleService( TestModules.CreateProcessJobRunnerCommand() ); await using var runnerService = new RunnerService( moduleService, moduleService, hookService ); using var exceptions = new IServiceBase[] { moduleService, runnerService, hookService }.EnableLogging(cancellationTokenSource); await hookService.InitializeAsync(cancellationToken); await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); }
public async Task SendTelegramVoiceMessageTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var hookService = new HookService { new (new Command("send-telegram-voice-message"), new Keys(Key.L, Key.RAlt), true), }; await using var moduleService = new StaticModuleService( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer(), TestModules.CreateTelegramRunner() ); await using var recognitionService = new RecognitionService(moduleService); await using var runnerService = new RunnerService( moduleService, moduleService, hookService ); using var exceptions = new IServiceBase[] { moduleService, runnerService, hookService }.EnableLogging(cancellationTokenSource); await hookService.InitializeAsync(cancellationToken); moduleService.Add(new RecognitionServiceRunner(recognitionService)); await Task.Delay(TimeSpan.FromSeconds(15), cancellationToken); }
public async Task SendTelegramVoiceMessageTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer(), TestModules.CreateTelegramRunner() ); await using var recognitionService = new RecognitionService(moduleService); await using var runnerService = new RunnerService(moduleService, moduleService, recognitionService); using var exceptions = new IServiceBase[] { moduleService, recognitionService, runnerService }.EnableLogging(cancellationTokenSource); moduleService.Add(new RecognitionServiceRunner(recognitionService)); var process = runnerService.Start(new Command("send-telegram-voice-message"), cancellationToken); await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); var value = await process.StopAsync(cancellationToken); Assert.AreNotEqual(0, value.Output.Data.Length); }
public async Task TelegramMessageTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateTelegramRunner() ); await using var runnerService = new RunnerService(moduleService); using var exceptions = new IServiceBase[] { moduleService, runnerService }.EnableLogging(cancellationTokenSource); await runnerService.RunAsync( new Command("telegram message", nameof(TelegramMessageTest)), cancellationToken); }
public async Task SimpleTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer() ); await using var recognitionService = new RecognitionService(moduleService); using var exceptions = new IServiceBase[] { moduleService, recognitionService }.EnableLogging(cancellationTokenSource); await recognitionService.Start_Wait5Seconds_Stop_TestAsync(cancellationToken); }
public async Task SelectScreenshotClipboardTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; using var app = await TestWpfApp.CreateAsync(cancellationToken); await using var hookService = new HookService { new (new Command( "process-sequence", "3", "select", "screenshot", "clipboard-set-image" ), new Keys(Key.RAlt), true), }; await using var moduleService = new StaticModuleService( new SelectRunner(app.Dispatcher), new ScreenshotRunner(), new ClipboardRunner(app.Dispatcher) ); await using var runnerService = new RunnerService( moduleService, moduleService, hookService ); using var exceptions = new IServiceBase[] { moduleService, runnerService, hookService }.EnableLogging(cancellationTokenSource); moduleService.Add(new ProcessSequenceRunner(runnerService)); await hookService.InitializeAsync(cancellationToken); await Task.Delay(TimeSpan.FromSeconds(15), cancellationToken); await runnerService.WaitAllAsync(cancellationToken); }
public async Task TelegramAudioTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateTelegramRunner() ); await using var runnerService = new RunnerService(moduleService); using var exceptions = new IServiceBase[] { moduleService, runnerService }.EnableLogging(cancellationTokenSource); await runnerService.RunAsync( new Command("telegram audio", new Value(string.Empty, nameof(TelegramAudioTest)) { Data = ResourcesUtilities.ReadFileAsBytes("test.mp3"), }), cancellationToken); }
public async Task LongJobTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateLongJobRunnerCommand() ); await using var runnerService = new RunnerService(moduleService); using var exceptions = new IServiceBase[] { moduleService, runnerService }.EnableLogging(cancellationTokenSource); var values = await runnerService.RunAsync( new Command("long-job", "5000"), cancellationToken); Assert.AreEqual(1, values.Length); Assert.AreEqual("5000", values[0].Input.Argument); }
public async Task SimpleTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(15)); var cancellationToken = cancellationTokenSource.Token; await using var deskbandService = new DeskbandService { ConnectedCommandFactory = _ => new Command("print", "Connected to H.DeskBand."), DisconnectedCommandFactory = _ => new Command("print", "Disconnected from H.DeskBand."), }; await using var moduleService = new StaticModuleService( TestModules.CreateTimerNotifierWithDeskbandDateTimeEach1Seconds(), TestModules.CreateRunnerWithPrintCommand() ); await using var runnerService = new RunnerService( moduleService, moduleService, deskbandService ); using var exceptions = new IServiceBase[] { moduleService, runnerService, deskbandService }.EnableLogging(cancellationTokenSource); moduleService.Add(new DeskbandServiceRunner(deskbandService)); await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); try { await runnerService.RunAsync( new Command("deskband", "clear-preview"), cancellationToken); } catch (OperationCanceledException) { // ignore cancelling on Github Actions. } }
public async Task RussianNameTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; using var app = await TestWpfApp.CreateAsync(cancellationToken); await using var moduleService = new StaticModuleService( new AliasRunner( new Command("sequence", "2", "clipboard-set-text", "keyboard CTRL+V"), "вставь"), new KeyboardRunner(), new ClipboardRunner(app.Dispatcher), new SequenceRunner() ); await using var runnerService = new RunnerService(moduleService, moduleService); using var exceptions = new IServiceBase[] { moduleService, runnerService }.EnableLogging(cancellationTokenSource); await runnerService.RunAsync(Command.Parse("вставь 123"), cancellationToken); }