Esempio n. 1
0
 public void UpdateProductInOrderToDifferentOption()
 {
     Order order = new Order();
     Product product = new Product { Title = "Test Product", ProductId = 1,OptionId = 1,OptionTitle = "Option1", Price=50};
     order.Add(product, 2, "F", 50);
     Assert.IsTrue(order.NumberOfItems == 2);
     Assert.IsTrue(order.ContainsProduct(product));
     Assert.IsTrue(order.PaymentTotal == 100);
     Product updateProduct = new Product { Title = "Test Product", ProductId = 1, OptionId = 2, OptionTitle = "Option2",Price=50 };
     order.Update(product, updateProduct, 6, "F", 50);
     Assert.IsTrue(order.NumberOfItems == 6);
     Assert.IsTrue(order.ContainsProduct(updateProduct));
     Assert.IsFalse(order.ContainsProduct(product));
     Assert.IsTrue(order.PaymentTotal == 300);
 }
Esempio n. 2
0
 public void ShouldNotUpdateWhereNotExistingProductInOrder()
 {
     Order order = new Order();
     Product product = new Product { Title = "Test Product", ProductId = 1, OptionId = 1, OptionTitle = "Option1",Price=50 };
     var operationStatus = order.Update(product, product, 6, "F", 50);
     Assert.IsTrue(operationStatus.Status == false);
     Assert.IsTrue(operationStatus.MessageCode == "CPX.ItemNotInOrder");
 }
Esempio n. 3
0
 public void UpdateProductInOrder()
 {
     Order order = new Order();
     Product product = new Product { Title = "Test Product", ProductId = 1, Price = 50 };
     var orderOperationStatus = order.Add(product, 2, "F", 50);
     Assert.IsTrue(orderOperationStatus.Status);
     Assert.IsTrue(order.NumberOfItems == 2);
     Assert.IsTrue(order.ContainsProduct(product));
     Assert.IsTrue(order.PaymentTotal == 100);
     orderOperationStatus = order.Update(product, product, 6, "F", 50);
     Assert.IsTrue(orderOperationStatus.Status);
     Assert.IsTrue(order.NumberOfItems == 6);
     Assert.IsTrue(order.ContainsProduct(product));
     Assert.IsTrue(order.PaymentTotal == 300);
 }
Esempio n. 4
0
 public void ShouldNotUpdateItemToExistingProduct()
 {
     Order order = new Order();
     Product product = new Product {Title = "Test Product", ProductId = 1, OptionId = 1, OptionTitle = "Option1",Price=50};
     order.Add(product, 2, "F", 50);
     Assert.IsTrue(order.NumberOfItems == 2);
     Assert.IsTrue(order.ContainsProduct(product));
     Assert.IsTrue(order.PaymentTotal == 100);
     Product product2 = new Product
         {
             Title = "Test Product",
             ProductId = 1,
             OptionId = 2,
             OptionTitle = "Option2",
             Price=50
         };
     order.Add(product2, 2, "F", 50);
     Assert.IsTrue(order.NumberOfItems == 4);
     Assert.IsTrue(order.ContainsProduct(product2));
     Assert.IsTrue(order.PaymentTotal == 200);
     Product updateProduct = new Product
         {
             Title = "Test Product",
             ProductId = 1,
             OptionId = 2,
             OptionTitle = "Option2",
             Price=50
         };
     var operationStatus = order.Update(product, updateProduct, 6, "F", 50);
     Assert.IsTrue(operationStatus.Status == false);
     Assert.IsTrue(operationStatus.MessageCode == "CPX.ItemAlreadyInOrder");
 }