public async Task return_null_when_not_found_document()
        {
            //Arrange
            _documentRepository.Setup(r => r.GetAsync(_guid)).Returns(Task.FromResult((Document)null));
            var query = new GetDocumentById();

            //Act
            var handler = new GetDocumentByIdHandler(_documentRepository.Object, _logger.Object);
            var result  = await handler.HandleAsync(query);

            //Assert
            Assert.Null(result);
        }
Example #2
0
        public async Task return_null_when_getDocumentById_equal_null()
        {
            // Arrange
            GetDocumentById query = null;

            _mockDispatcher.Setup(r => r.QueryAsync(query)).ReturnsAsync((DocumentDto)null);

            // Act
            var controller = new DocumentsController(_mockDispatcher.Object);
            var result     = await controller.GetById(query);

            //Assert
            Assert.Null(result.Value);
            Assert.IsType <ActionResult <DocumentDto> >(result);
        }
Example #3
0
        public async Task return_items_when_getDocumentById_not_null()
        {
            // Arrange
            var query       = new GetDocumentById();
            var documentDto = new DocumentDto();

            _mockDispatcher.Setup(r => r.QueryAsync(query)).ReturnsAsync(documentDto);

            // Act
            var controller = new DocumentsController(_mockDispatcher.Object);
            var result     = await controller.GetById(query);

            //Assert
            Assert.NotNull(result.Result);
            Assert.IsType <ActionResult <DocumentDto> >(result);
        }
        public async Task return_expected_result()
        {
            //Arrange
            var document = new Document(_guid, null, null, _guid);

            _documentRepository.Setup(r => r.GetAsync(_guid)).ReturnsAsync(document);
            var query = new GetDocumentById();

            query.Id = _guid;

            //Act
            var handler = new GetDocumentByIdHandler(_documentRepository.Object, _logger.Object);
            var result  = await handler.HandleAsync(query);

            //Assert
            Assert.NotNull(result);
            Assert.Equal(document.Id, result.Id);
            Assert.Equal(document.ExternalId, result.ExternalId);
        }
Example #5
0
 public async Task <ActionResult <DocumentDto> > GetById([FromRoute] GetDocumentById query)
 => Single(await QueryAsync(query));