Пример #1
0
        public void OrderSystem_GetCartsForACustomer()
        {
            Cart firstCart  = null;
            Cart secondCart = null;
            MetaStorageCollectionBase <Cart> carts = null;
            Guid customerId;

            //first add fictitious carts into the db
            customerId = Guid.NewGuid();

            //Create cart 1. This cart is just used to get the lineitem meta class information
            try
            {
                firstCart = OrderHelper.CreateCart(customerId, "FirstTestCart");
                firstCart.AcceptChanges();
            }
            catch (Exception exc)
            {
                if (exc.Message == "'maxValue' must be greater than zero.\r\nParameter name: maxValue")
                {
                    Assert.Fail("Check your ApplicationId");
                }
                else
                {
                    throw exc;
                }
            }

            //Create cart 1. This cart is just used to get the lineitem meta class information
            try
            {
                secondCart = OrderHelper.CreateCart(customerId, "SecondTestCart");
                secondCart.AcceptChanges();
            }
            catch (Exception exc)
            {
                if (exc.Message == "'maxValue' must be greater than zero.\r\nParameter name: maxValue")
                {
                    Assert.Fail("Check your ApplicationId");
                }
                else
                {
                    throw exc;
                }
            }

            try
            {
                carts = Cart.LoadByCustomer(customerId);
            }
            catch (Exception exc)
            {
                Assert.Fail("Error calling Cart.LoadByCustomer method : " + exc.Message);
            }

            if (carts.Count != 2)
            {
                Assert.Fail("Incorrect number of carts found by Cart.LoadByCustomer(). Found: " + carts.Count);
            }

            //cleanup
            firstCart.Delete();
            firstCart.AcceptChanges();
            secondCart.Delete();
            secondCart.AcceptChanges();
        }