public async void Get_ThrowsOrderTaxNotFoundException_WhenToCountryNotProvided() { //Arrange OrderTax orderTax = null; var serviceMock = new Mock <ITaxCalculatorService>(); serviceMock.Setup(o => o.GetSalesTaxForOrder(It.IsAny <Order>())).ReturnsAsync(orderTax); var appSettingsMock = new Mock <IOptions <AppSettings> >(); var controller = new OrderTaxController(_mockLogger.Object, _mapper, serviceMock.Object, appSettingsMock.Object); // Act + Assert await Assert.ThrowsAsync <OrderTaxNotFoundException>(() => controller.GetOrderTax(new OrderTaxRequestDto())); }
public void Get_ReturnsOkResult_WhenToCountryProvidedAndValid() { //Arrange var orderTax = new OrderTax(); var serviceMock = new Mock <ITaxCalculatorService>(); serviceMock.Setup(o => o.GetSalesTaxForOrder(It.IsAny <Order>())).ReturnsAsync(orderTax); var appSettingsMock = new Mock <IOptions <AppSettings> >(); // Act var controller = new OrderTaxController(_mockLogger.Object, _mapper, serviceMock.Object, appSettingsMock.Object); var result = controller.GetOrderTax(new OrderTaxRequestDto { ToCountry = "US" }).Result; // Assert Assert.IsType <OkObjectResult>(result); }