當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。