Example #1
0
        public async void ReturnFalse_IfExceptionOccurs()
        {
            var exc = new Exception();

            _unitOfWork.Setup(mock => mock.ActivityRepository.Read(It.IsAny <int>()))
            .Throws(exc);
            var command = new ReadActivityCommand(10);

            var handler     = new ReadActivityHandler(_unitOfWork.Object);
            var returnValue = await handler.Handle(command, new CancellationToken());

            Assert.False((bool)returnValue);
        }
Example #2
0
        public async void ReturnActivity()
        {
            var activity1 = new Activity()
            {
                Created = DateTime.Now,
                Id      = 1
            };

            _unitOfWork.Setup(mock => mock.ActivityRepository.Read(It.IsAny <int>()))
            .Returns(Task.FromResult(activity1));

            var command     = new ReadActivityCommand(1);
            var handler     = new ReadActivityHandler(_unitOfWork.Object);
            var returnValue = await handler.Handle(command, new CancellationToken());

            Assert.NotNull(returnValue);
            Assert.Equal(activity1, returnValue);
        }