Пример #1
0
        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);
        }
Пример #2
0
        public async Task TelegramTest()
        {
            using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
            var cancellationToken = cancellationTokenSource.Token;

            await using var container = IoCTests.CreateContainer(
                            TestModules.CreateDefaultRecorder(),
                            TestModules.CreateDefaultRecognizer(),
                            TestModules.CreateTelegramRunner(),
                            TestModules.CreateAliasRunnerCommand("telegram", "телеграмм", "отправь", "отправить")
                            );
            using var exceptions = container.EnableLoggingForServices(cancellationTokenSource);

            await container.Resolve <RecognitionService>().Start_Wait5Seconds_Stop_TestAsync(cancellationToken);
        }
Пример #3
0
        public async Task BaseTest()
        {
            using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
            var cancellationToken = cancellationTokenSource.Token;

            await using var container = CreateContainer(
                            TestModules.CreateDefaultRecorder(),
                            TestModules.CreateDefaultRecognizer(),
                            TestModules.CreateRunnerWithPrintCommand()
                            );
            using var exceptions = container.EnableLoggingForServices(cancellationTokenSource);

            var recognitionService = container.Resolve <RecognitionService>();

            await recognitionService.Start5SecondsStart5SecondsStopTestAsync(cancellationToken);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        public async Task RepeatTest()
        {
            using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
            var cancellationToken = cancellationTokenSource.Token;

            await using var container = IoCTests.CreateContainer(
                            TestModules.CreateDefaultRecorder(),
                            TestModules.CreateDefaultRecognizer(),
                            TestModules.CreateDefaultSynthesizer(),
                            TestModules.CreateDefaultPlayer(),
                            new IntegrationRunner(),
                            TestModules.CreateAliasRunnerCommand("say", "повтори", "повторить", "скажи")
                            );
            using var exceptions = container.EnableLoggingForServices(cancellationTokenSource);

            await container.Resolve <RecognitionService>().Start_Wait5Seconds_Stop_TestAsync(cancellationToken);

            var runnerService = container.Resolve <RunnerService>();
            await runnerService.WaitAllAsync(cancellationToken);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }
Пример #9
0
        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.
            }
        }
Пример #10
0
        public async Task TorrentTest()
        {
            using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(5));
            var cancellationToken = cancellationTokenSource.Token;

            await using var container = IoCTests.CreateContainer(
                            TestModules.CreateDefaultRecorder(),
                            TestModules.CreateDefaultRecognizer(),
                            TestModules.CreateDefaultSynthesizer(),
                            TestModules.CreateDefaultPlayer(),
                            TestModules.CreateDefaultSearcher(),
                            new TorrentRunner(),
                            TestModules.CreateRunnerWithPrintCommand(),
                            new IntegrationRunner(),
                            TestModules.CreateAliasRunnerCommand("torrent", "смотреть")
                            );
            using var exceptions = container.EnableLoggingForServices(cancellationTokenSource);

            var recognitionService = container.Resolve <RecognitionService>();
            await recognitionService.Start_Wait5Seconds_Stop_TestAsync(cancellationToken);

            var runnerService = container.Resolve <RunnerService>();
            await runnerService.WaitAllAsync(cancellationToken);
        }