Пример #1
0
        public async Task Handler_ShouldReturnTags_LimitedToMax()
        {
            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var query = new GetTagsCrossPlantQuery(1);
                var dut   = new GetTagsCrossPlantQueryHandler(context, _plantCacheMock.Object, _plantProvider);

                var result = await dut.Handle(query, default);

                Assert.AreEqual(1, result.Data.Count);
            }
        }
Пример #2
0
        public async Task Handler_ShouldReturnTags_WithAllPropertiesSet()
        {
            Project projectA;
            Project projectB;
            Tag     standardTag;
            Tag     siteTag;

            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                projectA = context.Projects.Single(p => p.Id == _projectAId);
                projectB = context.Projects.Single(p => p.Id == _projectBId);
                projectB.Close();

                standardTag = context.Tags.Include(t => t.Requirements).Single(t => t.Id == _standardTagId);
                standardTag.StartPreservation();
                siteTag          = context.Tags.Include(t => t.Requirements).Single(t => t.Id == _siteTagId);
                siteTag.IsVoided = true;

                standardTag.AddAction(new Action(standardTag.Plant, "AcA", "AcA desc", null));
                siteTag.AddAction(new Action(siteTag.Plant, "AcB", "AcB desc", _timeProvider.UtcNow));
                context.SaveChangesAsync().Wait();

                _timeProvider.ElapseWeeks(standardTag.Requirements.Single().IntervalWeeks);
            }

            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var query = new GetTagsCrossPlantQuery();
                var dut   = new GetTagsCrossPlantQueryHandler(context, _plantCacheMock.Object, _plantProvider);

                var result = await dut.Handle(query, default);

                var tagDtos = result.Data;

                var standardTagDto = tagDtos.Single(t => t.Id == standardTag.Id);
                AssertTag(standardTagDto, standardTag, _plantA, projectA);
                AssertJourneySpecificDataOnStandardTag(standardTagDto);
                var siteTagDto = tagDtos.Single(t => t.Id == siteTag.Id);
                AssertTag(siteTagDto, siteTag, _plantB, projectB);
                AssertJourneySpecificDataOnSiteTag(siteTagDto);

                Assert.IsTrue(siteTagDto.ProjectIsClosed);
                Assert.AreEqual(ActionStatus.HasOpen, standardTagDto.ActionStatus);
                Assert.AreEqual(ActionStatus.HasOverdue, siteTagDto.ActionStatus);
                Assert.IsFalse(standardTagDto.IsVoided);
                Assert.IsTrue(siteTagDto.IsVoided);
                Assert.AreEqual(PreservationStatus.Active, standardTagDto.Status);
                Assert.AreEqual(PreservationStatus.NotStarted, siteTagDto.Status);
                Assert.IsTrue(standardTagDto.ReadyToBePreserved);
                Assert.IsFalse(siteTagDto.ReadyToBePreserved);
            }
        }