本文整理汇总了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
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}