Esempio n. 1
0
        public async Task return_null_when_not_found_document()
        {
            //Arrange
            _documentRepository.Setup(r => r.GetDocumentByExternalIdAsync(_query)).Returns(Task.FromResult((Document)null));

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

            //Assert
            Assert.Null(result);
        }
Esempio n. 2
0
        public async Task return_expected_result()
        {
            //Arrange
            var document = new Document(_guid, null, null, _guid);

            _documentRepository.Setup(r => r.GetDocumentByExternalIdAsync(_query)).ReturnsAsync(document);

            //Act
            var handler = new GetDocumentByExternalIdHandler(_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);
        }