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


C# Cart.AddItem方法代码示例

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


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

示例1: Can_Send_Email

        public void Can_Send_Email() {

            // Arrange - create and populate a cart
            Cart cart = new Cart();
            cart.AddItem(new Product { ProductID = 1, Name = "Banana", Price = 10M }, 2);
            cart.AddItem(new Product { ProductID = 2, Name = "Apple", Price = 5M }, 2);

            // Arrange - create and populate some shipping details
            ShippingDetails shipDetails = new ShippingDetails {
                Name = "Joe Smith",
                Line1 = "Apartment 4a",
                Line2 = "123 West Street",
                City = "Northtown",
                State = "GA",
                Country = "USA",
                Zip = "12345"
            };

            // Arrange - create the test-specific email settings
            EmailSettings settings = new EmailSettings {
            
                // put test specific settings here
                WriteAsFile = true
            };

            // Arrange - create the EmailOrderProcessor class
            EmailOrderProcessor proc = new EmailOrderProcessor(settings);

            // Act - process the order
            proc.ProcessOrder(cart, shipDetails);

            // NOTE - there is assert in this test

        }
开发者ID:evkap,项目名称:AspNetMvcTestApp,代码行数:34,代码来源:EmailOrderProcessorTest.cs

示例2: AddItem_AddExistingItem_QtyIncreased

 public void AddItem_AddExistingItem_QtyIncreased()
 {
     Product p1 = new Product { ProductName = "P1", ProductID = 1 };
     Cart cart = new Cart();
     cart.AddItem(p1, 2);
     cart.AddItem(p1, 1);
     CartLine[] lineCollection = cart.Lines.ToArray();
     Assert.IsTrue(lineCollection.Length == 1);
     Assert.AreEqual(p1.ProductName, lineCollection[0].Product.ProductName);
     Assert.AreEqual(3, lineCollection[0].Quantity);
 }
开发者ID:vinhchung,项目名称:SportsStore,代码行数:11,代码来源:CartTest.cs

示例3: Calculate_Card_Total

        public void Calculate_Card_Total()
        {
            Product p1 = new Product { ProductID = 1, Name = "P1",Price=100 };
            Product p2 = new Product { ProductID = 2, Name = "P2",Price=150 };

            Cart target = new Cart();
            target.AddItem(p1, 1);
            target.AddItem(p2, 1);
            decimal res= target.ComputeTotalValue();

            Assert.AreEqual(res, 250);
        }
开发者ID:SergioKritskiy,项目名称:SportStore,代码行数:12,代码来源:CartTest.cs

示例4: Calculate_Car_Total

        public void Calculate_Car_Total()
        {
            Product p1 = new Product { ProductID = 1, Name = "P1", Price=10 };
            Product p2 = new Product { ProductID = 2, Name = "P2", Price=5};

            Cart target = new Cart();

            target.AddItem(p1, 1);
            target.AddItem(p2, 3);

            Assert.AreEqual(target.ComputeTotalValue(), 25);
        }
开发者ID:pasena,项目名称:SportsStore,代码行数:12,代码来源:CartTest.cs

示例5: AddItem_NewItem_Added

 public void AddItem_NewItem_Added()
 {
     Product p1 = new Product { ProductName = "P1", ProductID = 1 };
     Product p2 = new Product { ProductName = "P2", ProductID = 2 };
     Cart cart = new Cart();
     cart.AddItem(p1, 2);
     cart.AddItem(p2, 1);
     CartLine[] lineCollection = cart.Lines.ToArray();
     Assert.IsTrue(lineCollection.Length == 2);
     Assert.AreEqual(p1.ProductName, lineCollection[0].Product.ProductName);
     Assert.AreEqual(p2.ProductName, lineCollection[1].Product.ProductName);
 }
开发者ID:vinhchung,项目名称:SportsStore,代码行数:12,代码来源:CartTest.cs

示例6: Delete_All_Lines_From_Cart

        public void Delete_All_Lines_From_Cart()
        {
            Cart target = new Cart(); // TODO: Initialize to an appropriate value

            target.AddItem(products[0], 5);
            target.AddItem(products[1], 2);
            target.AddItem(products[2], 3);

            target.Clear();

            Assert.IsTrue( target.Lines.Count() == 0);
        }
开发者ID:najamsk,项目名称:SportsStore,代码行数:12,代码来源:CartTest.cs

示例7: CalculateCartTotal

        public void CalculateCartTotal()
        {
            Product p1 = new Product() { Id = 1, Name = "P1", Price = 100M};
            Product p2 = new Product() { Id = 2, Name = "P2", Price = 50M};
            Cart target = new Cart();

            target.AddItem(p1, 1);
            target.AddItem(p2, 1);
            target.AddItem(p1, 3);
            decimal result = target.ComputeTotalValue();

            Assert.AreEqual(result, 450M);
        }
开发者ID:MichalZawadzki,项目名称:SportsStore,代码行数:13,代码来源:CartTests.cs

示例8: Add_New_Lines_To_Cart

        public void Add_New_Lines_To_Cart()
        {
            Product p1 = new Product { ProductID = 1, Name = "P1" };
            Product p2 = new Product { ProductID = 2, Name = "P2" };

            Cart target = new Cart();
            target.AddItem(p1,1);
            target.AddItem(p2, 1);
            CartLine[] res = target.Lines.ToArray();

            Assert.AreEqual(res.Length,2);
            Assert.AreEqual(res[0].Product, p1);
            Assert.AreEqual(res[1].Product, p2);
        }
开发者ID:SergioKritskiy,项目名称:SportStore,代码行数:14,代码来源:CartTest.cs

示例9: Calculate_Cart_Total

        public void Calculate_Cart_Total()
        {
            var p1 = new Product { ProductID = 1, Name = "P1", Price = 100M };
            var p2 = new Product { ProductID = 2, Name = "P2", Price = 50M };

            var target = new Cart();

            target.AddItem(p1, 1);
            target.AddItem(p2, 1);
            target.AddItem(p1, 3);
            decimal result = target.ComputeTotalValue();

            Assert.AreEqual(result, 450M);
        }
开发者ID:Meleagre,项目名称:SportsStore,代码行数:14,代码来源:CartTests.cs

示例10: CanAddNewLines

        public void CanAddNewLines()
        {
            Product p1 = new Product() { ProductID = 1, Name = "P1" };
            Product p2 = new Product() { ProductID = 2, Name = "P2" };

            Cart cart = new Cart();

            cart.AddItem(p1, 1);
            cart.AddItem(p2, 1);

            Assert.AreEqual(2, cart.Lines.Count());
            Assert.AreEqual(1, cart.Lines.Single(x => x.Product.ProductID == p1.ProductID).Quantity);
            Assert.AreEqual(1, cart.Lines.Single(x => x.Product.ProductID == p2.ProductID).Quantity);
        }
开发者ID:Peska,项目名称:SportsStore,代码行数:14,代码来源:CartTests.cs

示例11: Calculate_Cart_Total

 public void Calculate_Cart_Total()
 {
     // Arrange - create some test products
     Product p1 = new Product { ProductID = 1, Name = "P1", Price = 100M };
     Product p2 = new Product { ProductID = 2, Name = "P2", Price = 50M };
     // Arrange - create a new cart
     Cart target = new Cart();
     // Act
     target.AddItem(p1, 1);
     target.AddItem(p2, 1);
     target.AddItem(p1, 3);
     decimal result = target.ComputeTotalValue(); // Assert
     Assert.AreEqual(result, 450M);
 }
开发者ID:jorgepkim,项目名称:SportsStore,代码行数:14,代码来源:CartTests.cs

示例12: Can_Add_New_Lines

        public void Can_Add_New_Lines()
        {
            var p1 = new Product {ProductId = 1, Name = "P1"};
            var p2 = new Product {ProductId = 2, Name = "P2"};

            var target = new Cart();

            target.AddItem(p1,1);
            target.AddItem(p2,2);
            var results = target.Lines.ToArray();
            Assert.AreEqual(results.Length, 2);
            Assert.AreEqual(results[0].Product, p1);
            Assert.AreEqual(results[1].Product, p2);
        }
开发者ID:trupak,项目名称:SportsStore,代码行数:14,代码来源:CartTests.cs

示例13: Add_New_Cart_Lines

        public void Add_New_Cart_Lines()
        {
            Product p1 = new Product { ProductID = 1, Name = "Apple" };
            Product p2 = new Product { ProductID = 2, Name = "Orange" };

            Cart target = new Cart();

            target.AddItem(p1, 1);
            target.AddItem(p2, 1);
            CartLine[] results = target.Lines.ToArray();

            Assert.AreEqual(results[0].Product, p1);
            Assert.AreEqual(results[1].Product, p2);
        }
开发者ID:rialhstu,项目名称:Online-Shopping,代码行数:14,代码来源:Carttests3.cs

示例14: Can_Clear_Contents

        public void Can_Clear_Contents()
        {
            Product p1 = new Product { ProductID = 1, Name = "P1", Price = 100M };
            Product p2 = new Product { ProductID = 2, Name = "P2", Price = 50M };

            Cart target = new Cart();

            target.AddItem(p1, 1);
            target.AddItem(p2, 1);

            target.Clear();

            Assert.AreEqual(target.Lines.Count(), 0);
        }
开发者ID:akuczynski,项目名称:SportsStore,代码行数:14,代码来源:CartTest.cs

示例15: CanAddNewLines

        public void CanAddNewLines()
        {
            Product p1 = new Product() { Id = 1, Name = "P1" };
            Product p2 = new Product() { Id = 2, Name = "P2" };
            Cart target = new Cart();

            target.AddItem(p1, 1);
            target.AddItem(p2, 1);
            CartLine[] results = target.Lines.ToArray();

            Assert.AreEqual(results.Length, 2);
            Assert.AreEqual(results[0].Product, p1);
            Assert.AreEqual(results[1].Product, p2);
        }
开发者ID:MichalZawadzki,项目名称:SportsStore,代码行数:14,代码来源:CartTests.cs


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