Beispiel #1
0
        public async void GetTaxForOrder_Expect_Sucsess()
        {
            // Setup
            var mockResponse = new GetOrderSalesTaxResponse()
            {
                SalesTax = new SalesTax
                {
                    amount_to_collect  = 12.90,
                    Order_total_amount = 124.88,
                    jurisdictions      = new Jurisdictions
                    {
                        city    = "Saint Pete",
                        country = "US"
                    }
                }
            };

            var fakeRequest = new GetOrderSalesTaxRequest {
            };

            _apiClient.Setup(x => x.PostAsync <GetOrderSalesTaxResponse>(It.IsAny <string>(), It.IsAny <object>()))
            .Returns(Task.FromResult(mockResponse)).Verifiable();

            // Act
            var actualResponse = await _taxRepository.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.jurisdictions);
            Assert.Equal("Saint Pete", actualResponse.SalesTax.jurisdictions.city);
        }
        /// <summary>
        ///  This method is used to fetch the sales tax that should be collected for a given order.
        /// </summary>
        /// <param name="getOrderSalesTaxRequest"></param>
        /// <returns>GetOrderSalesTaxResponse</returns>
        public async Task <GetOrderSalesTaxResponse> GetOrderSalesTax(GetOrderSalesTaxRequestModel getOrderSalesTaxRequest)
        {
            // Map Partner Request
            var apiRequest = _taxProviderMapper.MapGetOrderSalesTaxRequest(getOrderSalesTaxRequest);

            // Process Request
            var response = await _taxRepository.GetOrderSalesTax(apiRequest);

            // Return Response
            return(response);
        }