Пример #1
0
        public void Success_CreateProduct()
        {
            //Arrange
            int     index;
            string  result;
            Product product;

            //Act
            index   = 0;
            product = new Product
            {
                Name  = "ClassLibrary1 - Test product database - CreatePtoduct",
                Price = product_price + index
            };

            result = db_product.CreateProduct(product);

            //Assert
            Assert.AreEqual("Success", result);
        }
Пример #2
0
        public void Initialize()
        {
            db_product     = DB_Product.GetInstance();
            db_order       = DB_Order.GetInstance();
            db_orderdetail = DB_OrderDetail.GetInstance();
            db_user        = DBCustomUser.GetInstance();
            int index = 0;

            //Creates test user
            user = new CustomUser
            {
                Username = "******",
                Password = "******",
                Email    = "ClassLibrary1 - Test OrderDetail Database - User",
                Wallet   = 5000000.0,
            };

            db_user.CreateUser(user);

            //loop for test products and test orders.
            while (index < 100)
            {
                //Creates test product
                Product product = new Product
                {
                    Name  = "ClassLibrary1 - Test OrderDetail Database - Product",
                    Price = 1500.0
                };

                //creates test order.
                Order order = new Order
                {
                    Price     = 100.0,
                    IsShipped = true,
                    Username  = user.Username
                };

                db_order.CreateOrder(order);
                db_product.CreateProduct(product);
                index++;
            }

            products     = db_product.FindProductByName("ClassLibrary1 - Test OrderDetail Database - Product");
            orders       = db_order.FindOrderByUsername(user.Username);
            orderdetails = new List <OrderDetail>();
        }
Пример #3
0
        public void Initialize()
        {
            int index     = 0;
            int max_index = 100;

            db_user        = DBCustomUser.GetInstance();
            db_product     = DB_Product.GetInstance();
            db_userproduct = DB_UserProduct.GetInstance();
            Product product;

            user = new CustomUser
            {
                Username = "******",
                Password = "******",
                Email    = "ClassLibriry1 - Test UserProduct Database - User",
                Wallet   = 5000.0,
                IsActive = true,
                LoggedIn = true
            };

            db_user.CreateUser(user);

            while (index < max_index)
            {
                product = new Product
                {
                    Name  = "ClassLibriry1 - Test UserProduct Database - Product",
                    Price = 50.0 + (double)index
                };

                db_product.CreateProduct(product);
                index++;
            }

            products = db_product.FindProductByPriceHigher(25.0);
        }
Пример #4
0
 /// <summary>
 /// Creates a product.
 /// </summary>
 /// <param name="product"></param>
 /// <returns>string</returns>
 public string Create(Product product)
 {
     return(db_product.CreateProduct(product));
 }