public async Task <IActionResult> ReadAllTitle()
        {
            var command = new ReadAllTitleCommand();
            var result  = await this._mediator.Send(command);

            if (result == null)
            {
                return(new BadRequestObjectResult("Something went wrong"));
            }

            return(new OkObjectResult(result));
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
Exemple #4
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);
        }