Exemple #1
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 #2
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 #3
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();
        }