public async Task <IActionResult> GetProduct(GetProductRequest request) { var response = await _getProductHandler.HandleAsync(request); var result = MakeActionResult(response); return(result); }
public async Task return_null_when_not_found_document() { //Arrange _productRepository.Setup(r => r.GetAsync(_guid)).Returns(Task.FromResult((Product)null)); var query = new GetProduct(); //Act var handler = new GetProductHandler(_productRepository.Object, _logger.Object); var result = await handler.HandleAsync(query); //Assert Assert.Null(result); }
public async Task return_expected_result() { //Arrange var product = new Product(_guid, "", "", 1, _guid); _productRepository.Setup(r => r.GetAsync(_guid)).ReturnsAsync(product); var query = new GetProduct(); query.Id = _guid; //Act var handler = new GetProductHandler(_productRepository.Object, _logger.Object); var result = await handler.HandleAsync(query); //Assert Assert.NotNull(result); Assert.Equal(product.Id, result.Id); Assert.Equal(product.CategoryId, result.CategoryId); }