Exemple #1
0
        public async Task Handler_ShouldReturnModifiedAction()
        {
            DateTime?modifiedTime;

            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var openAction = context.Actions.Single(a => a.Id == _openActionId);
                openAction.Title = "Changed title";
                _timeProvider.Elapse(new TimeSpan(1, 1, 1, 1));
                context.SaveChangesAsync().Wait();
                modifiedTime = openAction.ModifiedAtUtc;
            }

            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var query = new GetActionDetailsQuery(_tagId, _openActionId);
                var dut   = new GetActionDetailsQueryHandler(context);

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

                Assert.IsNotNull(result);
                Assert.AreEqual(ResultType.Ok, result.ResultType);

                var actionDetailDto = result.Data;

                AssertModifiedAction(actionDetailDto, _testDataSet.CurrentUser, modifiedTime);
            }
        }
Exemple #2
0
        public async Task Handler_ShouldReturnNotFound_IfActionIsNotFound()
        {
            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var query = new GetActionDetailsQuery(_tagId, 0);
                var dut   = new GetActionDetailsQueryHandler(context);

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

                Assert.IsNotNull(result);
                Assert.AreEqual(ResultType.NotFound, result.ResultType);
                Assert.IsNull(result.Data);
            }
        }
Exemple #3
0
        public async Task Handler_ShouldReturnOpenAction()
        {
            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var query = new GetActionDetailsQuery(_tagId, _openActionId);
                var dut   = new GetActionDetailsQueryHandler(context);

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

                Assert.IsNotNull(result);
                Assert.AreEqual(ResultType.Ok, result.ResultType);

                var actionDetailDto = result.Data;
                AssertAction(actionDetailDto, _openAction, false);
                AssertNotModifiedAction(actionDetailDto);
            }
        }