public void CreateProductShould()
        {
            ProductType newProductType        = new ProductType("Home Decor");
            int         typeid                = _productTypeManager.AddProductType(newProductType);
            Product     product               = new Product(typeid, "Rug", 5, "Awesome shag rug - 8x10", 125.99f, 1);
            int         productThatWasCreated = _productManager.CreateProduct(product);

            Assert.IsType <int>(productThatWasCreated);
        }
        public void AddProductType()
        {
            ProductType newProductTypeToTest = new ProductType("Appliance");
            int         typeid = _productTypeManager.AddProductType(newProductTypeToTest);

            Assert.True(typeid != 0);
        }
Ejemplo n.º 3
0
        public void AddProductToOrderShould()
        {
            CustomerManager    _customerManager    = new CustomerManager(_db);
            ActiveCustomer     _activeManager      = new ActiveCustomer();
            ProductManager     _productManager     = new ProductManager(_db);
            ProductTypeManager _productTypeManager = new ProductTypeManager(_db);
            var newCustomerId = _customerManager.AddCustomer(new Customer("Bob", "Some Street", "City", "TN", 12345, "5555555555"));

            _activeManager.setActiveCustomerId(newCustomerId);
            var newProductTypeId = _productTypeManager.AddProductType(new ProductType("taco"));
            var newProductId     = _productManager.CreateProduct(new Product(newProductTypeId, "taco", 25, "string description", 25, newCustomerId));
            var orderId          = _orderManager.CreateOrder();
            var orderProductId   = _orderManager.AddProductToOrder(newProductId, orderId);

            Assert.IsType <int>(orderProductId);
        }
        public void GetAllProductTypesThatExist()
        {
            List <ProductType> typesList = _ProductTypeManager.GetProductTypes();

            Assert.Empty(typesList);

            ProductType type = new ProductType()
            {
                ProductTypeId = 1,
                Name          = "shoe"
            };

            _ProductTypeManager.AddProductType(type);
            typesList = _ProductTypeManager.GetProductTypes();
            Assert.NotEmpty(typesList);
        }
Ejemplo n.º 5
0
        // Method called from Program.cs switch case: 4
        // Accepts 3 arguments, Instance of ProductManager, ProductTypeManager, and an int containing Customer ID
        // this method prompts user to first define new productType then product
        // Authored by : Tamela Lerma
        public static void DoAction(ProductManager prodManager, int custId, ProductTypeManager prodType)
        {
            Console.Clear();
            int     counter = 1;
            int     prodTypeId;
            int     choice;           // used to store selected menu key value  T.L.
            bool    isANumber = true; // used to check that number value is entered   T.L.
            Product product   = new Product();

            product.customerId = custId; // set CustomerId on Product from int that is passed in DoAction Method    T.L.

            List <ProductType> prodList = prodType.GetProductTypes();

            Console.WriteLine("Select Product Type");

            foreach (ProductType item in prodList)
            {
                Console.WriteLine($"{counter}. {item.Name}");
                counter++;
            }
            Console.WriteLine($"{counter}. Add New Product Type");
            Console.Write(">");

            choice = int.Parse(Console.ReadLine());

            if (counter == choice)
            {
                Console.Clear();
                Console.WriteLine("Enter Type of Product");
                prodTypeId = prodType.AddProductType(Console.ReadLine());
            }
            else
            {
                prodTypeId = prodList[choice - 1].Id;
            }

            product.productTypeId = prodTypeId;
            // Last Id entered into DB is returned in  a ProductTypeManager ClassMethod
            // AddProductType returns that ID
            // that ID for the new ProductType is stored in an Int
            // Authored By : Tamela Lerma
            // The ProductTypeId property for product is set from this variable  T.L.

            do
            {
                // set title
                Console.WriteLine("Enter Product Name");
                product.title = Console.ReadLine();
                Console.Write(">");
            } while (product.title == "");

            do
            {
                // set description
                Console.WriteLine("Enter Product Description");
                product.description = Console.ReadLine();
                Console.Write(">");
            } while (product.description == "");


            do
            {
                Console.WriteLine("Enter Product Price");
                try {
                    // set price
                    product.price = double.Parse(Console.ReadLine());
                    Console.Write(">");
                    isANumber = true;
                } catch (System.FormatException) {
                    Console.Clear();
                    Program.Warning("Invalid entry, try again.");
                    isANumber = false;
                }
            }while (isANumber == false);


            do
            {
                Console.WriteLine("Enter Quantity");
                try {
                    // set quantity
                    product.quantity = int.Parse(Console.ReadLine());
                    Console.Write(">");
                    isANumber = true;
                } catch (System.FormatException) {
                    Console.Clear();
                    Program.Warning("Invalid entry, try again.");
                    isANumber = false;
                }
            } while (isANumber == false);
            Console.Clear();
            // Call Method from ProductManager Class and pass in new Product Object to be added to DB  T.L.
            prodManager.AddProduct(product);
            Program.Warning("Product added.");
        }
        // This method requires 1 arguments to set
        // returns ProductTypeId
        // Authored by : Tamela Lerma
        public void AddNewProductType(string name)
        {
            int id = _register.AddProductType(name);

            Assert.True(id != 0);
        }