Beispiel #1
0
        public void CalculateOutputFormYearJob_Success()
        {
            var date = new DateTime(2019, 2, 1);

            var dbContext = TypiconDbContextFactory.Create();
            var jobRepo   = new JobRepository();

            var yearHandler = CalculateModifiedYearJobHandlerTest.Build(dbContext, jobRepo);
            var yearJob     = new CalculateModifiedYearJob(1, 2019);

            jobRepo.Create(yearJob);

            Task task = yearHandler.ExecuteAsync(yearJob);

            task.Wait();

            var weekHandler = Build(dbContext, jobRepo);
            var weekJob     = new CalculateOutputFormWeekJob(1, 1, date);

            jobRepo.Create(weekJob);

            task = weekHandler.ExecuteAsync(weekJob);
            task.Wait();

            var queryProcessor = QueryProcessorFactory.Create();

            var week = queryProcessor.Process(new OutputWeekQuery(1, date, new OutputFilter()
            {
                Language = "cs-ru"
            }));

            Assert.AreEqual(true, week.Success);
        }
        public async Task HostingService_OutputForm()
        {
            var date = new DateTime(2019, 2, 1);

            var dbContext = TypiconDbContextFactory.Create();
            var jobRepo   = new JobRepository();

            var yearHandler = CalculateModifiedYearJobHandlerTest.Build(dbContext, jobRepo);
            var yearJob     = new CalculateModifiedYearJob(1, 2019);

            jobRepo.Create(yearJob);

            Task task = yearHandler.ExecuteAsync(yearJob);

            task.Wait();

            var weekHandler = CalculateOutputFormWeekJobTest.Build(dbContext, jobRepo);
            var weekJob     = new CalculateOutputFormWeekJob(1, 1, date);

            jobRepo.Create(weekJob);

            task = weekHandler.ExecuteAsync(weekJob);
            task.Wait();

            var service = new JobAsyncHostedService(jobRepo, CommandProcessorFactory.Create(dbContext));

            await service.StartAsync(CancellationToken.None);

            while (jobRepo.GetAll().Count() > 0)
            {
                Thread.Sleep(50);
            }

            var queryProcessor = QueryProcessorFactory.Create();

            var week = queryProcessor.Process(new OutputWeekQuery(1, date, new OutputFilter()
            {
                Language = "cs-ru"
            }));

            Assert.AreEqual(true, week.Success);
        }