public async Task GivenWeAreRetrievingACustomerById_WhenCustomerIsNotFound_ThenShouldReturnNotFound() { _queryBrokerMoq.Setup(x => x.SendAsync(It.IsAny <GetCustomer>())) .ReturnsAsync((Customer)null !); var controller = new CustomerQueryController(_queryBrokerMoq.Object, _mapper); var actionResult = await controller.GetCustomer(Customers.Customer1.Id); var notFoundResult = actionResult as NotFoundResult; Assert.NotNull(actionResult); Assert.NotNull(notFoundResult); }
public async Task GivenWeAreRetrievingACustomerById_WhenSuccessful_ThenCorrectCustomerShouldBeReturned() { _queryBrokerMoq.Setup(x => x.SendAsync(It.IsAny <GetCustomer>())) .ReturnsAsync(_mapper.Map <Customer>(Customers.Customer1)); var controller = new CustomerQueryController(_queryBrokerMoq.Object, _mapper); var actionResult = await controller.GetCustomer(Customers.Customer1.Id); var okResult = Assert.IsType <OkObjectResult>(actionResult); var value = (CustomerView)okResult.Value !; Assert.Equal(CustomerViews.Customer1.Id, value.Id); }