Exemple #1
0
        static void TestCustomerList2Index()
        {
            CustomerList2 cl = new CustomerList2();
            Customer      c  = new Customer();
            Customer      c2 = new Customer("Nohm", "Chomskey", "*****@*****.**");

            for (int i = 0; i < 4; i++)
            {
                cl.Add(c);
            }
            cl.Add(c2);
            for (int i = 0; i < 10; i++)
            {
                cl.Add(c);
            }

            Console.WriteLine("Testing indexer getter for CustomerList2. Placing 15 items in the list.");
            Console.WriteLine("Expecting 15 customers to be in the list.");
            Console.WriteLine("Getting " + cl.Count + " customers");
            Console.WriteLine("Testing indexer setter for CustomerList2.");
            cl[5] = c2;
            Console.WriteLine("Expecting the customer at index 4 to be Nohm Chomskey.");
            Console.WriteLine("The customer at index 4 is " + cl[5].FirstName + " " + cl[5].LastName);
            Console.WriteLine();
        }
Exemple #2
0
        static void TestCustomerList2Indexers()
        {
            CustomerList2 cList2 = new CustomerList2();
            Customer      c1     = new Customer("John", "Smith", "*****@*****.**");
            Customer      c3     = new Customer("Jake", "Andrews", "*****@*****.**");

            cList2.Add(c1);
            cList2.Add("Elsa", "Jacobs", "*****@*****.**");
            cList2 += c3;

            Console.WriteLine("Testing indexer");
            Console.WriteLine("Get product with index 0");
            Customer c4 = cList2[0];

            Console.WriteLine("Expecting John. " + c4);
            Console.WriteLine("Should not change list. Expecting count of 3 " + cList2.Count);
            Console.WriteLine("Expecting list of 3 customers.  John is the first element in list:\n" + cList2);
        }
Exemple #3
0
        // CustomerList2 Combo Tests
        static void TestCustomerList2Combo()
        {
            Console.WriteLine("Testing Wholesale and Retail in same list");
            CustomerList2 cList2 = new CustomerList2();

            // Add wholesale customers to the list
            WholesaleCustomer wholecust1 = new WholesaleCustomer("Brandon", "Bobs", "*****@*****.**", "Bobs Motors");

            cList2.Add(wholecust1);
            WholesaleCustomer wholecust2 = new WholesaleCustomer("Mary", "Scampi", "*****@*****.**", "Scampi Shrimp");

            cList2.Add(wholecust2);

            // Add retail customers to the list w/overloaded operators
            RetailCustomer retailcust1 = new RetailCustomer("Aaron", "Baker", "*****@*****.**", "(555) 555-5555");

            cList2 += retailcust1;
            RetailCustomer retailcust2 = new RetailCustomer("Cathi", "Davis", "*****@*****.**", "(555) 777-7777");

            cList2 += retailcust2;

            Console.WriteLine("Expecting list of 4 customers, 1st 2 wholesale, next 2 retail \n" + cList2);
            Console.WriteLine();

            Console.WriteLine("Testing foreach");
            Console.WriteLine("All first names. Expecting: Brandon Mary Aaron Cathi");
            string allFirstNames = "";

            //foreach loop to get all first names in both lists, then combine
            foreach (Customer cust in cList2)
            {
                allFirstNames = allFirstNames + cust.FirstName + " ";
            }
            Console.WriteLine(allFirstNames);
            Console.WriteLine();

            Console.WriteLine("Testing Remove and - operator");
            cList2.Remove(wholecust2);
            cList2 -= retailcust2;
            Console.WriteLine("Expecting 1 retail and 1 wholesale \n" + cList2);
        }
Exemple #4
0
        static void TestCustomerList2Find()
        {
            CustomerList2 cl = new CustomerList2();
            Customer      c  = new Customer();
            Customer      c2 = new Customer("Nohm", "Chomskey", "*****@*****.**");
            Customer      c3;

            for (int i = 0; i < 4; i++)
            {
                cl.Add(c);
            }
            cl.Add(c2);
            for (int i = 0; i < 10; i++)
            {
                cl.Add(c);
            }

            Console.WriteLine("Testing email indexer for CustomerList2.");
            Console.WriteLine("Expecting to find the customer with the email nohm@chomskey and not the email [email protected].");
            if (cl["*****@*****.**"].Email == "*****@*****.**")
            {
                c3 = cl["*****@*****.**"];
                Console.WriteLine("Found " + c3.FirstName + " " + c3.LastName + " with the email " + c3.Email);
            }
            else
            {
                Console.WriteLine("Customer with email [email protected] not found.");
            };
            if (cl["*****@*****.**"].Email == "*****@*****.**")
            {
                c3 = cl["*****@*****.**"];
                Console.WriteLine("Found " + c3.FirstName + " " + c3.LastName + " with the email " + c3.Email);
            }
            else
            {
                Console.WriteLine("Customer with email [email protected] not found.");
            }
            Console.WriteLine();
        }
Exemple #5
0
        static void TestCustomerList2Remove()
        {
            CustomerList2 cList2 = new CustomerList2();
            Customer      c1     = new Customer("John", "Smith", "*****@*****.**");
            Customer      c3     = new Customer("Jake", "Andrews", "*****@*****.**");

            cList2.Add(c1);
            cList2.Add("Elsa", "Jacobs", "*****@*****.**");
            cList2 += c3;

            Console.WriteLine("Testing Remove");
            Console.WriteLine("Remove");
            cList2.Remove(c1);
            Console.WriteLine("Expecting count of 2 " + cList2.Count);
            Console.WriteLine("Expecting list of 2 customers: Removed John: \n" + cList2);

            cList2 -= c3;
            Console.WriteLine("- operator");
            Console.WriteLine("Expecting count of 1 " + cList2.Count);
            Console.WriteLine("Expecting list of 1 customer. Removed Jake: \n" + cList2);
            Console.WriteLine();
        }
Exemple #6
0
        static void TestCustomerList2Add()
        {
            CustomerList2 cList2 = new CustomerList2();
            Customer      c1     = new Customer("John", "Smith", "*****@*****.**");
            Customer      c3     = new Customer("Jake", "Andrews", "*****@*****.**");

            Console.WriteLine("Testing Add");
            cList2.Add(c1);
            Console.WriteLine("Add that takes a customer parameter");
            Console.WriteLine("Expecting count of 1 " + cList2.Count);
            Console.WriteLine("Expecting list of 1 customer: \n" + cList2);

            cList2.Add("Elsa", "Jacobs", "*****@*****.**");
            Console.WriteLine("Add that takes individual customer attributes and constructs customer");
            Console.WriteLine("Expecting count of 2 " + cList2.Count);
            Console.WriteLine("Expecting list of 2 customers: \n" + cList2);

            cList2 += c3;
            Console.WriteLine("+ operator");
            Console.WriteLine("Expecting count of 3 " + cList2.Count);
            Console.WriteLine("Expecting list of 3 customers:\n" + cList2);
            Console.WriteLine();
        }
Exemple #7
0
        static void TestCustomerList2Add()
        {
            CustomerList2 cList = new CustomerList2();
            Customer      c1    = new Customer(
                "Mickey", "Mouse", "*****@*****.**");
            Customer c3 = new Customer(
                "Minnie", "Mouse", "*****@*****.**");

            Console.WriteLine("Testing Add");
            cList.Add(c1);
            Console.WriteLine("Add that takes a Customer parameter");
            Console.WriteLine("Expecting count of 1 " + cList.Count);
            Console.WriteLine("Expecting list of 1 Customers:\n" + cList);
            cList.Add("Donald", "Duck", "*****@*****.**");
            Console.WriteLine("Add that takes individual Customer attributes and constructs a Customer");
            Console.WriteLine("Expecting count of 2 " + cList.Count);
            Console.WriteLine("Expecting list of 2 Customers:\n" + cList);
            cList += c3;
            Console.WriteLine("+ operator");
            Console.WriteLine("Expecting count of 3 " + cList.Count);
            Console.WriteLine("Expecting list of 3 Customers:\n" + cList);
            Console.WriteLine();
        }
Exemple #8
0
        static void TestCustomerList2()
        {
            Console.WriteLine("Testing retail and wholesale in same list.");
            CustomerList2     cList = new CustomerList2();
            WholesaleCustomer wc1   = new WholesaleCustomer("Amy", "Johnson", "*****@*****.**", "LCC");
            RetailCustomer    rc1   = new RetailCustomer("Juan", "Lopez", "*****@*****.**", "(541)-123-4567");

            cList.Add(wc1);
            cList += rc1;
            Console.WriteLine("Expecting list containing a wholesale customer, 'Amy Johnson', and a retail customer, 'Juan Lopez'\n" + cList);
            string allFirstNames = "";

            foreach (Customer c in cList)
            {
                allFirstNames = allFirstNames + " " + c.FirstName;
            }
            Console.WriteLine(allFirstNames);
        }
Exemple #9
0
        /// <summary>
        ///                                         CUSTOMER LIST 2 TESTING STARTS HERE
        /// </summary>


        static void TestCustomerList2AddRemove()
        {
            CustomerList2 cl = new CustomerList2();
            Customer      c  = new Customer("Nohm", "Chomskey", "*****@*****.**");

            cl.Add(c);

            Console.WriteLine("Testing add customer for CustomerList2.");
            Console.WriteLine("Expecting Nohm, Chomskey, [email protected], with one item in the list.");
            Console.WriteLine("Getting " + cl[0].GetDisplayText() + " with a total of " + cl.Count + " items.");
            Console.WriteLine();

            cl.Remove(c);

            Console.WriteLine("Testing remove customer for CustomerList2.");
            Console.WriteLine("Removing Nohm Chomskey. Expecting empty list.");
            Console.WriteLine("Getting " + cl.Count + " customers.");
            Console.WriteLine();
        }
Exemple #10
0
        static void TestCustomerList2Save()
        {
            CustomerList2   cl = new CustomerList2();
            Customer        c  = new Customer("Henry", "Davenport", "*****@*****.**");
            List <Customer> customers;

            Console.WriteLine("Testing CustomerList2 save.");
            Console.Write("Expecting ");
            customers = CustomerDB.GetCustomers();
            customers.Add(c);

            for (int i = 0; i < customers.Count; i++)
            {
                Console.WriteLine(customers[i].GetDisplayText());
            }

            for (int i = 0; i < customers.Count; i++)
            {
                cl.Add(customers[i]);
            }

            Console.Write("Getting ");
            cl.Save();
            customers = CustomerDB.GetCustomers();
            for (int i = 0; i < customers.Count; i++)
            {
                Console.WriteLine(customers[i].GetDisplayText());
            }
            Console.WriteLine();

            customers.RemoveAt(customers.IndexOf(c));
            CustomerList2 cl2 = new CustomerList2();

            for (int i = 0; i < customers.Count; i++)
            {
                cl2.Add(customers[i]);
            }
            cl2.Save();
        }