コード例 #1
0
ファイル: TotalToPayTests.cs プロジェクト: neozhu/Ecommerce
        public void ShouldBeTheTotalIfThereAreNoGiftCardsApplied()
        {
            var testableCartModel = new TestableCartModel(total: 100m)
            {
                AppliedGiftCards = new List<GiftCard>()
            };

            testableCartModel.TotalToPay.Should().Be(100m);
        }
コード例 #2
0
        public void IfShippingIsRequiredAndMethodNotSetAndSomePotentialMethodsShouldBeShippingNotSet()
        {
            var cartModel = new TestableCartModel(requiresShipping: true)
            {
                ShippingMethod = null,
                PotentiallyAvailableShippingMethods = new HashSet<IShippingMethod> { A.Fake<IShippingMethod>()}
            };

            cartModel.ShippingStatus.Should().Be(CartShippingStatus.ShippingNotSet);
        }
コード例 #3
0
        public void ShouldBeTheSumOfTheItemsPriceLessTheOrderTotalDiscount()
        {
            var model = new TestableCartModel(orderTotalDiscount: 10m)
            {
                Items = new List<CartItem>
                {
                    new CartItemBuilder().WithPricePreTax(10).WithTax(5).Build(),
                    new CartItemBuilder().WithPricePreTax(20).WithTax(5).Build(),
                    new CartItemBuilder().WithPricePreTax(30).WithTax(5).Build()
                }
            };

            model.TotalPreShipping.Should().Be(65);
        }
コード例 #4
0
        public void ShouldBeTheTotalIfTheSumOfTheAvailableAmountIsGreaterThanTheTotal()
        {
            var testableCartModel = new TestableCartModel(total: 50m)
            {
                AppliedGiftCards = new List<GiftCard>
                {
                    new GiftCardBuilder().WithAvailableAmount(10m).Build(),
                    new GiftCardBuilder().WithAvailableAmount(20m).Build(),
                    new GiftCardBuilder().WithAvailableAmount(30m).Build()
                }
            };

            testableCartModel.GiftCardAmount.Should().Be(50m);
        }
コード例 #5
0
        public void ShouldBeTheSumOfTheAvailableAmountOfTheGiftCardsApplied()
        {
            var testableCartModel = new TestableCartModel(total: 100m)
            {
                AppliedGiftCards = new List<GiftCard>
                {
                    new GiftCardBuilder().WithAvailableAmount(10m).Build(),
                    new GiftCardBuilder().WithAvailableAmount(20m).Build(),
                    new GiftCardBuilder().WithAvailableAmount(30m).Build()
                }
            };

            testableCartModel.GiftCardAmount.Should().Be(60m);
        }
コード例 #6
0
        public void IfShippingIsRequiredAndIsSetShouldBeShippingSet()
        {
            var cartModel = new TestableCartModel(requiresShipping: true){ShippingMethod = A.Fake<IShippingMethod>()};

            cartModel.ShippingStatus.Should().Be(CartShippingStatus.ShippingSet);
        }
コード例 #7
0
        public void IfShippingIsNotRequiredStatusShouldBeNotRequired()
        {
            var cartModel = new TestableCartModel(requiresShipping: false);

            cartModel.ShippingStatus.Should().Be(CartShippingStatus.ShippingNotRequired);
        }
コード例 #8
0
        public void ShouldBeOrderTotalDiscountPlusItemTotalIfThatAmountIsLessThanTHeOrderTotalPreDiscount()
        {
            var cartModel = new TestableCartModel(totalPreDiscount: 20m, orderTotalDiscount: 10m, itemDiscount: 5m);

            cartModel.DiscountAmount.Should().Be(15m);
        }
コード例 #9
0
        public void ShouldBeShippingTotalLessTax()
        {
            var cartModel = new TestableCartModel(shippingTotal: 10m, shippingTax: 1m);

            cartModel.ShippingPreTax.Should().Be(9m);
        }
コード例 #10
0
ファイル: TaxTests.cs プロジェクト: neozhu/Ecommerce
        public void ShouldBeTheItemTaxPlusTheShippingTax()
        {
            var model = new TestableCartModel(itemTax: 10m, shippingTax: 5m);

            model.Tax.Should().Be(15);
        }
コード例 #11
0
 public void PayPalShippingServiceTests_GetNoShipping_ShouldBe0WhenRequiresShippingAndAddressIsSet()
 {
     var testableCartModel = new TestableCartModel(requiresShipping: true) {ShippingAddress = new Address()};
     _payPalShippingService.GetNoShipping(testableCartModel).Should().Be("0");
 }
コード例 #12
0
ファイル: TotalTests.cs プロジェクト: neozhu/Ecommerce
        public void ShouldBeTheTotalPreShippingPlusTheShippingTotal()
        {
            var model = new TestableCartModel(totalPreShipping: 10m, shippingTotal: 5m);

            model.Total.Should().Be(15);
        }
コード例 #13
0
ファイル: TotalToPayTests.cs プロジェクト: neozhu/Ecommerce
        public void ShouldBeTheTotalLessTheAppliedGiftCardAvailableAmount()
        {
            var testableCartModel = new TestableCartModel(total: 100m, giftCardAmount:60m);

            testableCartModel.TotalToPay.Should().Be(40m);
        }