public async Task HandleGetAllJourneysQuery_ShouldReturnVoidedJourneys_WhenGettingVoided() { using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var journey = context.Journeys.Include(j => j.Steps).First(); journey.IsVoided = true; journey.Steps.ToList().ForEach(s => s.IsVoided = true); context.SaveChangesAsync().Wait(); } using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new GetAllJourneysQueryHandler(context); var result = await dut.Handle(new GetAllJourneysQuery(true), default); var journeys = result.Data.ToList(); Assert.AreEqual(1, journeys.Count); var journey = journeys.First(); Assert.IsTrue(journey.IsVoided); Assert.IsTrue(journey.Steps.All(s => s.IsVoided)); } }
public async Task HandleGetAllJourneysQuery_ShouldReturnNonVoidedJourneysOnly_WhenNotGettingVoided() { using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var dut = new GetAllJourneysQueryHandler(context); var result = await dut.Handle(new GetAllJourneysQuery(false), default); var journeys = result.Data.ToList(); Assert.AreEqual(1, journeys.Count); var journey = journeys.First(); Assert.IsFalse(journey.IsVoided); Assert.AreEqual(_journeyTitle, journey.Title); var steps = journey.Steps.ToList(); Assert.AreEqual(2, steps.Count); AssertStep(steps.ElementAt(0), _step1Title, _supplierModeId, _responsible1Id, _mode1Title, _responsible1Code, false, true); AssertStep(steps.ElementAt(1), _step2Title, _otherModeId, _responsible2Id, _mode2Title, _responsible2Code, false, false); } }