示例#1
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()));
        }
示例#2
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);
        }