Beispiel #1
0
 public TaxRateControllerTests()
 {
     _taxRateManager        = A.Fake <ITaxRateManager>();
     _configurationProvider = A.Fake <IConfigurationProvider>();
     _taxSettings           = new TaxSettings();
     _taxRateController     = new TaxRateController(_taxRateManager, _configurationProvider, _taxSettings, _getPricingMethodOptions);
 }
 public TaxRateControllerTests()
 {
     _taxRateManager = A.Fake<ITaxRateManager>();
     _configurationProvider = A.Fake<IConfigurationProvider>();
     _taxSettings = new TaxSettings();
     _taxRateController = new TaxRateController(_taxRateManager, _configurationProvider, _taxSettings);
 }
Beispiel #3
0
        public async void Get_ThrowsTaxRateNotFoundException_WhenZipNotProvided()
        {
            //Arrange
            TaxRate taxRate = null;

            var serviceMock = new Mock <ITaxCalculatorService>();

            serviceMock.Setup(o => o.GetTaxRateForLocation(It.IsAny <Location>())).ReturnsAsync(taxRate);

            var appSettingsMock = new Mock <IOptions <AppSettings> >();

            TaxRateController controller = new TaxRateController(_mockLogger.Object, _mapper, serviceMock.Object, appSettingsMock.Object);

            // Act + Assert
            await Assert.ThrowsAsync <TaxRateNotFoundException>(() => controller.GetTaxRate(new TaxRateRequestDto()));
        }
Beispiel #4
0
        public void Get_ReturnsOkResult_WhenZipProvidedAndValid()
        {
            //Arrange
            TaxRate taxRate = new TaxRate {
                CombinedRate = 10
            };

            var serviceMock = new Mock <ITaxCalculatorService>();

            serviceMock.Setup(o => o.GetTaxRateForLocation(It.IsAny <Location>())).ReturnsAsync(taxRate);

            var appSettingsMock = new Mock <IOptions <AppSettings> >();

            // Act
            TaxRateController controller = new TaxRateController(_mockLogger.Object, _mapper, serviceMock.Object, appSettingsMock.Object);
            var result = controller.GetTaxRate(new TaxRateRequestDto {
                Zip = "33602"
            }).Result;

            // Assert
            Assert.IsType <OkObjectResult>(result);
        }