Ejemplo n.º 1
0
        public async void ReturnListOfTitle()
        {
            _unitOfWork.Setup(mock => mock.TitleRepository.ReadAll())
            .Returns(Task.FromResult(list));

            var            command     = new ReadAllTitleCommand();
            var            handler     = new ReadAllTitleHandler(_unitOfWork.Object);
            List <DBTitle> returnValue = (List <DBTitle>) await handler.Handle(command, new CancellationToken());

            Assert.NotNull(returnValue);
            Assert.Equal(3, returnValue.Count);
        }
Ejemplo n.º 2
0
        public async void ReturnFalse_IfResultIsNull()
        {
            List <DBTitle> list = null;

            _unitOfWork.Setup(mock => mock.TitleRepository.ReadAll())
            .Returns(Task.FromResult(list));
            var command = new ReadAllTitleCommand();

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

            Assert.Null(returnValue);
        }
Ejemplo n.º 3
0
        public async void ReturnNull_IfExceptionOccurs()
        {
            var exc = new Exception();

            _unitOfWork.Setup(mock => mock.TitleRepository.ReadAll())
            .Throws(exc);
            var command = new ReadAllTitleCommand();

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

            Assert.Null(returnValue);
        }