当前位置: 首页>>代码示例>>C#>>正文


C# Basket.AddItemsToTheBasket方法代码示例

本文整理汇总了C#中Basket.AddItemsToTheBasket方法的典型用法代码示例。如果您正苦于以下问题:C# Basket.AddItemsToTheBasket方法的具体用法?C# Basket.AddItemsToTheBasket怎么用?C# Basket.AddItemsToTheBasket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Basket的用法示例。


在下文中一共展示了Basket.AddItemsToTheBasket方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShouldCheckOutTheSelectedItemsFromTheBasket

        public void ShouldCheckOutTheSelectedItemsFromTheBasket()
        {
            var item1 = new Item { ProductName = "Butter", PriceOfProduct = "3", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
            var item2 = new Item { ProductName = "Milk", PriceOfProduct = "2", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
            IBasket basket = new Basket();
            basket.AddItemsToTheBasket(item1);
            basket.AddItemsToTheBasket(item2);

            var checkout = new Checkout(basket);
            IList<Item> itemsForCheckout = checkout.ItemsSelectedForCheckOut().ToList();

            Assert.That(itemsForCheckout.Count, Is.EqualTo(2));
        }
开发者ID:rekhabothiraj,项目名称:ShoppingCart,代码行数:13,代码来源:BasketTests.cs

示例2: ShouldCalculateThePriceForTheChekedOutItems

        public void ShouldCalculateThePriceForTheChekedOutItems()
        {
            var item1 = new Item { ProductName = "Butter", PriceOfProduct = "3", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
            var item2 = new Item { ProductName = "Milk", PriceOfProduct = "2", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
            int totalPrice = 5;

            IBasket basket = new Basket();
            basket.AddItemsToTheBasket(item1);
            basket.AddItemsToTheBasket(item2);

            var checkout = new Checkout(basket);

            var actual = checkout.CalculatePriceForcheckOut();
            Assert.That(actual,Is.EqualTo(totalPrice));
        }
开发者ID:rekhabothiraj,项目名称:ShoppingCart,代码行数:15,代码来源:BasketTests.cs

示例3: ShouldAddSalePriceToTheItem

        public void ShouldAddSalePriceToTheItem()
        {
            var item1 = new Item { ProductName = "Butter", PriceOfProduct = "10", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013,11,12) };
            var item2 = new Item { ProductName = "Milk", PriceOfProduct = "20", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013,11,12) };
            var basket = new Basket();

            basket.AddItemsToTheBasket(item1);
            basket.AddItemsToTheBasket(item2);

            Assert.That(item1.SalePrice,Is.EqualTo(5));
            Assert.That(item2.SalePrice,Is.EqualTo(10));

            var checkout = new Checkout(basket);
            var calculatePriceForcheckOut = checkout.CalculatePriceForcheckOut();

            Assert.That(calculatePriceForcheckOut,Is.EqualTo(15));
        }
开发者ID:rekhabothiraj,项目名称:ShoppingCart,代码行数:17,代码来源:BasketTests.cs

示例4: ShouldAddItemsToTheBasket

        public void ShouldAddItemsToTheBasket()
        {
            var basket = new Basket();
            var item2 = new Item { NoOfProducts = 2, PriceOfProduct = "3", ProductName = "Milk", ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };

            int count = basket.AddItemsToTheBasket(item2).Count;

            Assert.That(count, Is.EqualTo(1));
        }
开发者ID:rekhabothiraj,项目名称:ShoppingCart,代码行数:9,代码来源:BasketTests.cs

示例5: ShouldDeleteItemFormTheBasket

        public void ShouldDeleteItemFormTheBasket()
        {
            var item2 = new Item { ProductName = "Butter", PriceOfProduct = "3", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
            var item3 = new Item { ProductName = "Butter", PriceOfProduct = "2", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };

            var basket = new Basket();

            basket.AddItemsToTheBasket(item3);
            basket.AddItemsToTheBasket(item2);

            basket.DeleteItemFromTheBasket(item2);

            Assert.That(basket.list.Count,Is.EqualTo(1));
        }
开发者ID:rekhabothiraj,项目名称:ShoppingCart,代码行数:14,代码来源:BasketTests.cs

示例6: ShouldRemoveItemsFromTheBasket

        public void ShouldRemoveItemsFromTheBasket()
        {
            //use mock
            var item1 = new Item { ProductName = "Butter", PriceOfProduct = "3", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
            var item2 = new Item { ProductName = "Milk", PriceOfProduct = "2", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
            var basket = new Basket();

            basket.AddItemsToTheBasket(item1);
            basket.AddItemsToTheBasket(item2);

            IList<Item> itemsFormTheBasket = basket.RemoveItemsFormTheBasket(item1);

            Assert.That(itemsFormTheBasket.Count, Is.EqualTo(1));
        }
开发者ID:rekhabothiraj,项目名称:ShoppingCart,代码行数:14,代码来源:BasketTests.cs

示例7: ShouldIncrementTheCountOfNoOfProductsWhenSameItemAdded

        public void ShouldIncrementTheCountOfNoOfProductsWhenSameItemAdded()
        {
            var item2 = new Item { ProductName = "Butter", PriceOfProduct = "3", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };
            var item3 = new Item { ProductName = "Butter", PriceOfProduct = "2", NoOfProducts = 2, ItemCreatedDate = new DateTime(2013, 09, 18), ItemExpiryDate = new DateTime(2013, 09, 21) };

            var basket = new Basket();

            IList<Item> listOfItems = basket.AddItemsToTheBasket(item3);
            Assert.That(listOfItems.Count, Is.EqualTo(1));

            listOfItems = basket.AddItemsToTheBasket(item2);
            Item listItem = listOfItems.FirstOrDefault(l => l.ProductName == item2.ProductName);
            if (listItem != null)
                Assert.That(listItem.NoOfProducts, Is.EqualTo(item3.NoOfProducts));
            Assert.That(listOfItems.Count, Is.EqualTo(1));
        }
开发者ID:rekhabothiraj,项目名称:ShoppingCart,代码行数:16,代码来源:BasketTests.cs


注:本文中的Basket.AddItemsToTheBasket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。