public GetDocumentByExternalIdHandlerTests() { _guid = Guid.NewGuid(); _query = new GetDocumentByExternalId(); _query.Id = _guid; _documentRepository = new Mock <IDocumentRepository>(); _logger = new Mock <ILogger <GetDocumentByExternalIdHandler> >(); }
public async Task return_null_when_getDocumentByExternalId_equal_null() { // Arrange GetDocumentByExternalId query = null; _mockDispatcher.Setup(r => r.QueryAsync(query)).ReturnsAsync((DocumentDto)null); // Act var controller = new DocumentsController(_mockDispatcher.Object); var result = await controller.GetByExternalId(query); //Assert Assert.Null(result.Value); Assert.IsType <ActionResult <DocumentDto> >(result); }
public async Task return_items_when_getDocumentByExternalId_not_null() { // Arrange var query = new GetDocumentByExternalId(); var documentDto = new DocumentDto(); _mockDispatcher.Setup(r => r.QueryAsync(query)).ReturnsAsync(documentDto); // Act var controller = new DocumentsController(_mockDispatcher.Object); var result = await controller.GetByExternalId(query); //Assert Assert.NotNull(result.Result); Assert.IsType <ActionResult <DocumentDto> >(result); }
public async Task <ActionResult <DocumentDto> > GetByExternalId([FromRoute] GetDocumentByExternalId query) => Single(await QueryAsync(query));
public async Task <Document> GetDocumentByExternalIdAsync(GetDocumentByExternalId query) => await _repository.GetAsync(p => p.ExternalId == query.Id);