예제 #1
0
        public void Cleanup()
        {
            List <Order> orders = db_order.FindOrderByUsername(user.Username);

            foreach (Order order in orders)
            {
                db_order.DeleteOrder(order.Id);
            }

            db_user.DeleteUser(user.Username);
        }
예제 #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
 /// <summary>
 /// Finds a list of orders by their username.
 /// </summary>
 /// <param name="username"></param>
 /// <returns><List<Order>/returns>
 public List <Order> FindByUsername(string username)
 {
     return(db_order.FindOrderByUsername(username));
 }