Ejemplo n.º 1
0
        private void DeleteCustomer()
        {
            _allCustomers = customerManipulator.GetAllCustomers();
EnterName:
            Console.Clear();
            ViewAllCustomers();
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("\n" +
                              "Enter the first and last name of the customer you wish to delete:\n");
            string[] fullName = Console.ReadLine().Split(' ');
            if (fullName != null && fullName.Length == 2)
            {
                string firstName  = fullName.ElementAt <string>(0);
                string lastName   = fullName.ElementAt <string>(1);
                bool   wasDeleted = customerManipulator.DeleteCustomer(firstName, lastName);
                if (wasDeleted)
                {
                    Console.WriteLine("Customer was successfully deleted.");
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine("Could not delete customer. Please try again.");
                    Console.ReadKey();
                    goto EnterName;
                }
            }
            else
            {
                PressAnyKey();
                goto EnterName;
            }
        }
Ejemplo n.º 2
0
        public void TestDeleteMethod()
        {
            // Arrange (initialize variables)
            var  newCustomer = new Customer("Casey", "McDonough", CustomerType.Past);
            bool wasDeleted  = false;

            customerTester.CreateCustomer(newCustomer);

            // Act (remove newCustomer from the field of customers)
            wasDeleted = customerTester.DeleteCustomer(newCustomer.FirstName, newCustomer.LastName);

            // Assert (that the Delete method returns true, and that the field of customers is empty)
            Assert.IsTrue(wasDeleted, "Delete failed.");
            Assert.IsTrue(customerTester.GetAllCustomers().Count == 0);
        }