Exemplo n.º 1
0
        public async void GetOrderSalesTax_ValidInput_Expect_Success(int amount, string fromCountry, string toCountry)
        {
            // Setup
            var mockResponse = new GetOrderSalesTaxResponse()
            {
                SalesTax = new SalesTax
                {
                    amount_to_collect  = 12.90,
                    Order_total_amount = 124.88,
                    breakdown          = new Breakdown
                    {
                        city_taxable_amount = 78,
                        city_tax_rate       = 7
                    },
                    jurisdictions = new Jurisdictions
                    {
                        city    = "Saint Pete",
                        country = "US"
                    }
                }
            };
            var fakeRequest = new GetOrderSalesTaxRequestModel
            {
                Amount       = amount,
                From_country = fromCountry,
                To_country   = toCountry
            };

            _taxRepository.Setup(x => x.GetOrderSalesTax(It.IsAny <GetOrderSalesTaxRequest>()))
            .Returns(Task.FromResult(mockResponse)).Verifiable();

            // Act
            var actualResponse = await _taxProvider.GetOrderSalesTax(fakeRequest) as GetOrderSalesTaxResponse;

            // Assert
            Assert.NotNull(actualResponse);
            Assert.NotNull(actualResponse.SalesTax);
            Assert.Equal(12.90, actualResponse.SalesTax.amount_to_collect);
            Assert.Equal(124.88, actualResponse.SalesTax.Order_total_amount);
            Assert.NotNull(actualResponse.SalesTax.breakdown);
            Assert.Equal(78, actualResponse.SalesTax.breakdown.city_taxable_amount);
            Assert.NotNull(actualResponse.SalesTax.jurisdictions);
            Assert.Equal("Saint Pete", actualResponse.SalesTax.jurisdictions.city);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetOrderSalesTax([FromBody] GetOrderSalesTaxRequestModel getOrderSalesTaxRequest)
        {
            var getOrderSalesTaxResponse = await _taxProvider.GetOrderSalesTax(getOrderSalesTaxRequest);

            return(Ok(getOrderSalesTaxResponse));
        }