Beispiel #1
0
 public void AddProductToOrder()
 {
     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);
 }
Beispiel #2
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);
 }
Beispiel #3
0
        public void ShouldReturnLocationEmailsCorrectly()
        {
            Order order = new Order();
            Product product = new Product
                {
                    Title = "Test Product",
                    ProductId = 1,
                    OptionId = 1,
                    OptionTitle = "Option1",
                    LocationEmail = "*****@*****.**",
                    Price=50
                };
            order.Add(product, 2, "F", 50);
            Assert.IsTrue(order.NumberOfItems == 2);
            Assert.IsTrue(order.ContainsProduct(product));
            var expectedEmailList = new List<string> {"*****@*****.**"};
            var actualEmailList = order.GetLocationEmails();

            Assert.AreEqual(expectedEmailList.Count,actualEmailList.Count);
            Assert.AreEqual(expectedEmailList[0],actualEmailList[0]);
            Product product2 = new Product
                {
                    Title = "Test Product 2",
                    ProductId = 2,
                    LocationEmail = "*****@*****.**",
                    Price=50
                };
            order.Add(product2, 2, "F", 50);
            Assert.IsTrue(order.NumberOfItems == 4);
            Assert.IsTrue(order.ContainsProduct(product2));

            expectedEmailList = new List<string> {"*****@*****.**", "*****@*****.**"};
            actualEmailList = order.GetLocationEmails();

            Assert.AreEqual(expectedEmailList.Count,actualEmailList.Count);
            Assert.AreEqual(expectedEmailList[0],actualEmailList[0]);
            Assert.AreEqual(expectedEmailList[1],actualEmailList[1]);

            //check that it only returns distinct email addresses
            Product product3 = new Product
            {
                Title = "Test Product 3",
                ProductId = 3,
                LocationEmail = "*****@*****.**",
                Price=50
            };
            order.Add(product3,2, "F", 50);
            Assert.IsTrue(order.NumberOfItems == 6);
            Assert.IsTrue(order.ContainsProduct(product3));

            actualEmailList = order.GetLocationEmails();
            Assert.AreEqual(expectedEmailList.Count,actualEmailList.Count);
            Assert.AreEqual(expectedEmailList[0],actualEmailList[0]);
            Assert.AreEqual(expectedEmailList[1],actualEmailList[1]);
        }
Beispiel #4
0
        public void ShouldUpdateQuantityAndEventDatesWhenAddingExistingEvent()
        {
            Order order = new Order();

            Product event1 = new Product { Title = "Test Event 1", ProductId = 1, StartDate = new DateTime(2014,08,1),FinishDate = new DateTime(2014,08,5), Price = 50 };
            order.Add(event1, 2, "F", 50);
            Assert.IsTrue(order.NumberOfItems == 2);
            Assert.IsTrue(order.ContainsProduct(event1));
            Assert.IsTrue(order.PaymentTotal == 100);
            Product event2 = new Product { Title = "Test Event 2", ProductId = 1, StartDate = new DateTime(2014,08,1),FinishDate = new DateTime(2014,08,4), Price = 50 };
            order.Add(event2, 3, "F", 50);
            Assert.IsTrue(order.NumberOfItems == 3);
            Assert.IsTrue(order.PaymentTotal == 150);
            Assert.IsTrue(order.ContainsProduct(event1));
            var eventInOrder = order.GetOrderLine(event1);
            Assert.IsTrue(eventInOrder.StartDate == new DateTime(2014, 08, 1));
            Assert.IsTrue(eventInOrder.FinishDate == new DateTime(2014, 08, 4));
        }
Beispiel #5
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");
 }