Beispiel #1
0
        public async Task GetTaxForOrder_Error()
        {
            _mockHttpMessageHandler.Protected().Setup <Task <HttpResponseMessage> >("SendAsync",
                                                                                    ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.BadRequest
            });

            var fromAddressWrongCountry = new Address(
                Guid.NewGuid(),
                "US",
                "92093",
                "CA",
                "La Jolla",
                "9500 Gilman Drive"
                );

            var toAddress = new Address(
                Guid.NewGuid(),
                "US",
                "90002",
                "CA",
                "Los Angeles",
                "1335 E 103rd St"
                );

            var order = new Order(Guid.NewGuid(), fromAddressWrongCountry, toAddress, new List <Address>(), 15m, 1.5m,
                                  new List <LineItem>());

            await Assert.ThrowsAsync <TaxJarTaxesForOrderException>(() => _taxJarCalculator.GetTaxForOrderAsync(order));
        }
        public async Task GetTaxForOrder_Success()
        {
            var fromAddressWrongCountry = new Address(
                Guid.NewGuid(),
                "US",
                "92093",
                "CA",
                "La Jolla",
                "9500 Gilman Drive"
                );

            var toAddress = new Address(
                Guid.NewGuid(),
                "US",
                "90002",
                "CA",
                "Los Angeles",
                "1335 E 103rd St"
                );

            var order = new Order(Guid.NewGuid(), fromAddressWrongCountry, toAddress, new List <Address>(), 15m, 1.5m,
                                  new List <LineItem>());
            var tax = await _taxJarCalculator.GetTaxForOrderAsync(order);

            Assert.Equal(0.095m, tax.Rate);
            Assert.Equal(15m, tax.TaxableAmount);
        }