Esempio n. 1
0
        public async Task GetTimePeriodLabels_NoObservations()
        {
            var release = new Release();

            var subject = new Subject();

            var releaseSubject1 = new ReleaseSubject
            {
                Release      = release,
                Subject      = subject,
                DataGuidance = "Subject 1 Guidance"
            };

            var statisticsDbContextId = Guid.NewGuid().ToString();

            await using (var statisticsDbContext = InMemoryStatisticsDbContext(statisticsDbContextId))
            {
                await statisticsDbContext.AddAsync(release);

                await statisticsDbContext.AddAsync(subject);

                await statisticsDbContext.AddAsync(releaseSubject1);

                await statisticsDbContext.SaveChangesAsync();
            }

            await using (var statisticsDbContext = InMemoryStatisticsDbContext(statisticsDbContextId))
            {
                var service = new TimePeriodService(statisticsDbContext);

                var result = service.GetTimePeriodLabels(subject.Id);

                Assert.Empty(result.From);
                Assert.Empty(result.To);
            }
        }
Esempio n. 2
0
        public async Task GetTimePeriodLabels_CorrectlyOrderWeeks()
        {
            var release = new Release();

            var subject = new Subject();

            var releaseSubject = new ReleaseSubject
            {
                Release      = release,
                Subject      = subject,
                DataGuidance = "Subject 1 Guidance"
            };

            var subjectObservation1 = new Observation
            {
                Subject        = subject,
                Year           = 2020,
                TimeIdentifier = Week9,
            };

            var subjectObservation2 = new Observation
            {
                Subject        = subject,
                Year           = 2020,
                TimeIdentifier = Week37,
            };

            var subjectObservation3 = new Observation
            {
                Subject        = subject,
                Year           = 2020,
                TimeIdentifier = Week8,
            };

            var statisticsDbContextId = Guid.NewGuid().ToString();

            await using (var statisticsDbContext = InMemoryStatisticsDbContext(statisticsDbContextId))
            {
                await statisticsDbContext.AddAsync(release);

                await statisticsDbContext.AddAsync(subject);

                await statisticsDbContext.AddAsync(releaseSubject);

                await statisticsDbContext.AddRangeAsync(
                    subjectObservation1,
                    subjectObservation2,
                    subjectObservation3);

                await statisticsDbContext.SaveChangesAsync();
            }

            await using (var statisticsDbContext = InMemoryStatisticsDbContext(statisticsDbContextId))
            {
                var service = new TimePeriodService(statisticsDbContext);

                var result = service.GetTimePeriodLabels(subject.Id);

                Assert.Equal("2020 Week 8", result.From);
                Assert.Equal("2020 Week 37", result.To);
            }
        }