public async Task WhenThereAreTimedOutJobs_thenThoseJobsAreIncludedInResult()
        {
            using (var sut = new InMemoryMetricsQueryDataContext())
            {
                await sut.Jobs.AddAsync(new JobModel
                {
                    JobType          = JobType.EarningsJob,
                    AcademicYear     = 2122,
                    CollectionPeriod = 1,
                    DcJobId          = 1,
                    Ukprn            = 1,
                    Status           = JobStatus.TimedOut,
                    DcJobSucceeded   = true,
                    StartTime        = DateTimeOffset.Now.AddMinutes(-149)
                });

                await sut.SaveChangesAsync();

                var periodEndStartJob = new JobModel {
                    JobType = JobType.PeriodEndStartJob, AcademicYear = 2122, CollectionPeriod = 1, StartTime = DateTimeOffset.Now, DcJobId = 123
                };

                var actual = await sut.GetOutstandingOrTimedOutJobs(periodEndStartJob, CancellationToken.None);

                actual.Count.Should().Be(1);
                actual[0].DcJobId.Should().Be(1);
                actual[0].Ukprn.Should().Be(1);
            }
        }
        public async Task IgnoresThePeriodEndStartJobAndReturnsEmptyResult()
        {
            using (var sut = new InMemoryMetricsQueryDataContext())
            {
                await sut.Jobs.AddAsync(new JobModel
                {
                    JobType          = JobType.PeriodEndStartJob,
                    AcademicYear     = 2122,
                    CollectionPeriod = 1,
                    DcJobId          = 1,
                    Ukprn            = 1,
                    Status           = JobStatus.InProgress,
                    DcJobSucceeded   = true,
                    StartTime        = DateTimeOffset.Now
                });

                await sut.SaveChangesAsync();

                var periodEndStartJob = new JobModel {
                    JobType = JobType.PeriodEndStartJob, AcademicYear = 2122, CollectionPeriod = 1, StartTime = DateTimeOffset.Now, DcJobId = 123
                };

                var actual = await sut.GetOutstandingOrTimedOutJobs(periodEndStartJob, CancellationToken.None);

                actual.Count.Should().Be(0);
            }
        }
Ejemplo n.º 3
0
        public async Task When_One_SubmissionSummary_Exists_For_Given_List_Of_JobIds_Then_The_Result_Does_Only_Include_Outstanding_JobId()
        {
            using (var sut = new InMemoryMetricsQueryDataContext())
            {
                await sut.SubmissionSummaries.AddAsync(new SubmissionSummaryModel
                {
                    AcademicYear     = 2122,
                    CollectionPeriod = 1,
                    JobId            = 1,
                    Ukprn            = 1,
                });

                await sut.SaveChangesAsync();

                var outstandingJobs = new List <OutstandingJobResult> {
                    new OutstandingJobResult {
                        DcJobId = 1, Ukprn = 1
                    }, new OutstandingJobResult {
                        DcJobId = 2, Ukprn = 2
                    }
                };

                var actual = sut.DoSubmissionSummariesExistForJobs(outstandingJobs);

                actual.Count.Should().Be(1);
                actual[0].Should().Be(2);
            }
        }
        public async Task WhenThereAreNoOutstandingJobs_thenReturnsEmptyResult()
        {
            using (var sut = new InMemoryMetricsQueryDataContext())
            {
                var periodEndStartJob = new JobModel {
                    JobType = JobType.PeriodEndStartJob, AcademicYear = 2122, CollectionPeriod = 1, StartTime = DateTimeOffset.Now, DcJobId = 123
                };

                var actual = await sut.GetOutstandingOrTimedOutJobs(periodEndStartJob, CancellationToken.None);

                actual.Count.Should().Be(0);
            }
        }
        public async Task WhenThereAreJobsFromPreviousAcademicYearAndCurrentAcademicYear_thenOnlyReturnsJobsFromCurrentAcademicYear()
        {
            using (var sut = new InMemoryMetricsQueryDataContext())
            {
                await sut.Jobs.AddAsync(new JobModel
                {
                    JobType          = JobType.EarningsJob,
                    AcademicYear     = 2122,
                    CollectionPeriod = 1,
                    DcJobId          = 1,
                    Ukprn            = 1,
                    Status           = JobStatus.InProgress,
                    DcJobSucceeded   = true,
                    StartTime        = DateTimeOffset.Now.AddMinutes(-148)
                });

                await sut.Jobs.AddAsync(new JobModel
                {
                    JobType          = JobType.EarningsJob,
                    AcademicYear     = 2021,
                    CollectionPeriod = 14,
                    DcJobId          = 14,
                    Ukprn            = 14,
                    Status           = JobStatus.InProgress,
                    DcJobSucceeded   = true,
                    StartTime        = DateTimeOffset.Now.AddMinutes(-148)
                });

                await sut.SaveChangesAsync();

                var periodEndStartJob = new JobModel {
                    JobType = JobType.PeriodEndStartJob, AcademicYear = 2122, CollectionPeriod = 1, StartTime = DateTimeOffset.Now, DcJobId = 123
                };

                var actual = await sut.GetOutstandingOrTimedOutJobs(periodEndStartJob, CancellationToken.None);

                actual.Count.Should().Be(1);
                actual[0].DcJobId.Should().Be(1);
                actual[0].Ukprn.Should().Be(1);
            }
        }
Ejemplo n.º 6
0
        public void When_All_SubmissionSummaries_AreOutStanding_For_Given_List_Of_JobIds_Then_The_Result_Includes_All_Outstanding_JobId()
        {
            using (var sut = new InMemoryMetricsQueryDataContext())
            {
                //Do nothing in DB setup as we are asserting that all the jobs are outstanding

                var outstandingJobs = new List <OutstandingJobResult> {
                    new OutstandingJobResult {
                        DcJobId = 1, Ukprn = 1
                    }, new OutstandingJobResult {
                        DcJobId = 2, Ukprn = 2
                    }
                };

                var actual = sut.DoSubmissionSummariesExistForJobs(outstandingJobs);

                actual.Count.Should().Be(2);
                actual[0].Should().Be(1);
                actual[1].Should().Be(2);
            }
        }