Beispiel #1
0
        public async void GetTaxRate_Expect_Sucsess()
        {
            // Setup
            var mockResponse = new GetTaxRateResponse()
            {
                Rate = new TaxRate
                {
                    City       = "Saint Pete",
                    Zip        = "33701",
                    State_rate = "10.99"
                }
            };

            _apiClient.Setup(x => x.GetAsync <GetTaxRateResponse>(It.IsAny <string>()))
            .Returns(Task.FromResult(mockResponse)).Verifiable();

            // Act
            var actualResponse = await _taxRepository.GetTaxRateResponse("https://sample.com") as GetTaxRateResponse;

            // Assert
            // Assert
            Assert.NotNull(actualResponse);
            Assert.NotNull(actualResponse.Rate);
            Assert.Equal("Saint Pete", actualResponse.Rate.City);
            Assert.Equal("33701", actualResponse.Rate.Zip);
            Assert.Equal("10.99", actualResponse.Rate.State_rate);
        }
        /// <summary>
        ///  This method is used to get the sales tax rates for a given location.
        ///  Calls TaxRepository.GetTaxRateResponse, which in turn calls TaxJar API to fetch the required details
        /// </summary>
        /// <param name="getTaxRateRequest"></param>
        /// <returns>GetTaxRateResponse</returns>
        public async Task <GetTaxRateResponse> GetTaxRates(GetTaxRateRequest getTaxRateRequest)
        {
            // Validate Request Data
            _taxProviderValidator.ValidateGetTaxRateRequest(getTaxRateRequest);

            // Map Downstream Api request
            var getTaxRatesPartnerUri = _taxProviderMapper.MapGetTaxRatesUri(getTaxRateRequest);

            // Process Request
            var response = await _taxRepository.GetTaxRateResponse(getTaxRatesPartnerUri);

            // Return Response
            return(response);
        }