public static async Task StartRecord5SecondsStopRecordTestAsync( this RunnerService service, CancellationToken cancellationToken = default) { await service.RunAsync(new Command("start-recognition"), cancellationToken); await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); await service.RunAsync(new Command("stop-recognition"), 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 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 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); }