コード例 #1
0
        public async Task HandleGetJourneyByIdQueryHandler_UnknownId_ShouldReturnNull()
        {
            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var dut    = new GetJourneyByIdQueryHandler(context);
                var result = await dut.Handle(new GetJourneyByIdQuery(1525, false), default);

                Assert.IsNull(result.Data);
            }
        }
コード例 #2
0
        public async Task HandleGetJourneyByIdQueryHandler_AfterTagsAddedToAStep_ShouldReturnAllStepsInUse()
        {
            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var dut    = new GetJourneyByIdQueryHandler(context);
                var result = await dut.Handle(new GetJourneyByIdQuery(_testDataSet.Journey1With2Steps.Id, true), default);

                var journey = result.Data;
                Assert.IsTrue(journey.Steps.All(s => s.IsInUse));
            }
        }
コード例 #3
0
        public async Task HandleGetJourneyByIdQueryHandler_KnownId_ShouldNotReturnVoidedStepsInJourneyWhenExcludedInRequest()
        {
            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var dut    = new GetJourneyByIdQueryHandler(context);
                var result = await dut.Handle(new GetJourneyByIdQuery(_testDataSet.Journey1With2Steps.Id, false), default);

                var journey = result.Data;
                var steps   = journey.Steps.ToList();
                Assert.AreEqual(1, steps.Count);
            }
        }
コード例 #4
0
        public async Task HandleGetJourneyByIdQueryHandler_JourneyWithSteps_ShouldReturnJourneyInUse()
        {
            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var journeyId = _testDataSet.Journey2With1Step.Id;

                var dut    = new GetJourneyByIdQueryHandler(context);
                var result = await dut.Handle(new GetJourneyByIdQuery(journeyId, true), default);

                var journey = result.Data;
                Assert.IsTrue(journey.IsInUse);
            }
        }
コード例 #5
0
        public async Task HandleGetJourneyByIdQueryHandler_BeforeTagsAddedToStep_ShouldReturnNoStepsInUse()
        {
            int journeyId;

            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                journeyId = AddJourneyWithStep(context, "J3", "Step1", _testDataSet.Mode1, _testDataSet.Responsible1).Id;
            }

            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var dut    = new GetJourneyByIdQueryHandler(context);
                var result = await dut.Handle(new GetJourneyByIdQuery(journeyId, true), default);

                var journey = result.Data;
                Assert.IsFalse(journey.Steps.Any(s => s.IsInUse));
            }
        }
コード例 #6
0
        public async Task HandleGetJourneyByIdQueryHandler_KnownId_ShouldReturnJourney()
        {
            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var dut    = new GetJourneyByIdQueryHandler(context);
                var result = await dut.Handle(new GetJourneyByIdQuery(_testDataSet.Journey1With2Steps.Id, true), default);

                var journey = result.Data;
                Assert.AreEqual(_testDataSet.Journey1With2Steps.Title, journey.Title);

                var steps = journey.Steps.ToList();
                Assert.AreEqual(2, steps.Count);

                var step = steps.Single(s => s.Id == _step1Id);
                Assert.IsNotNull(step.Mode);
                Assert.IsNotNull(step.Responsible);
                Assert.AreEqual(_testDataSet.Mode1.Id, step.Mode.Id);
                Assert.AreEqual(_testDataSet.Responsible1.Id, step.Responsible.Id);
                Assert.AreEqual(_autoTransferMethodOnStep1, step.AutoTransferMethod);

                step = steps.Single(s => s.Id == _step2Id);
                Assert.AreEqual(_autoTransferMethodOnStep2, step.AutoTransferMethod);
            }
        }