Пример #1
0
        public void PaymentShippingOptionInitsWithNoArgs()
        {
            var paymentShippingOption = new PaymentShippingOption();

            Assert.NotNull(paymentShippingOption);
            Assert.IsType <PaymentShippingOption>(paymentShippingOption);
        }
Пример #2
0
        private static IReadOnlyList <PaymentShippingOption> CreateShippingOptions(ShoppingCart shoppingCart)
        {
            List <PaymentShippingOption> paymentShippingOptions = new List <PaymentShippingOption>();

            ShippingType selectedShippingType = shoppingCart.ShippingType;
            IReadOnlyDictionary <ShippingType, ShoppingCartCostsSummary> cartShippingOptions = shoppingCart.CalculateShippingOptions();

            ShoppingCartCostsSummary costsOfSelectedShipping = cartShippingOptions[selectedShippingType];

            foreach (var kvp in cartShippingOptions)
            {
                ShippingType             shippingType = kvp.Key;
                ShoppingCartCostsSummary costs        = kvp.Value;

                PaymentShippingOption shippingOption = new PaymentShippingOption(
                    label: ShippingTypeStringUtilities.CreateShippingOptionTitle(shippingType, costs, costsOfSelectedShipping),
                    selected: (shippingType == selectedShippingType),
                    tag: shippingType.ToString(),
                    amount: CreateCurrencyAmount(costs.Shipping));

                paymentShippingOptions.Add(shippingOption);
            }

            return(paymentShippingOptions);
        }
Пример #3
0
        private IReadOnlyList <PaymentShippingOption> CreateShippingOptions()
        {
            List <PaymentShippingOption> paymentShippingOptions = new List <PaymentShippingOption>();

            PaymentShippingOption shippingOption = new PaymentShippingOption("Standard", new PaymentCurrencyAmount("2.00", "USD"), false, "STANDARD");

            paymentShippingOptions.Add(shippingOption);

            shippingOption = new PaymentShippingOption("Two Day", new PaymentCurrencyAmount("5.99", "USD"), false, "TWODAY");
            paymentShippingOptions.Add(shippingOption);

            return(paymentShippingOptions);
        }
Пример #4
0
        public void PaymentShippingOptionInits()
        {
            var id       = "shippingOptionId";
            var label    = "label";
            var amount   = new PaymentCurrencyAmount();
            var selected = true;

            var paymentShippingOption = new PaymentShippingOption(id, label, amount, selected);

            Assert.NotNull(paymentShippingOption);
            Assert.IsType <PaymentShippingOption>(paymentShippingOption);
            Assert.Equal(id, paymentShippingOption.Id);
            Assert.Equal(label, paymentShippingOption.Label);
            Assert.Equal(amount, paymentShippingOption.Amount);
            Assert.Equal(selected, paymentShippingOption.Selected);
        }
Пример #5
0
        private static IReadOnlyList <PaymentShippingOption> GetShippingOptions()
        {
            List <PaymentShippingOption> paymentShippingOptions = new List <PaymentShippingOption>();

            PaymentShippingOption option = new PaymentShippingOption(
                "Free (3-5 business days)",
                new PaymentCurrencyAmount("0.00", "GBP"),
                false,
                "FREE");

            paymentShippingOptions.Add(option);

            option = new PaymentShippingOption("Next day", new PaymentCurrencyAmount("5.99", "GBP"), false, "ONEDAY");
            paymentShippingOptions.Add(option);

            option = new PaymentShippingOption(
                "Priority (by 13:00 next day)",
                new PaymentCurrencyAmount("6.99", "GBP"),
                false,
                "PRIORITY");
            paymentShippingOptions.Add(option);

            return(paymentShippingOptions);
        }