private void EditCustomer() { _allCustomers = customerManipulator.GetAllCustomers(); Console.Clear(); ViewAllCustomers(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("\n" + "Enter the first and last name of the customer you wish to edit:\n"); string[] fullName = Console.ReadLine().Split(' '); string firstName = fullName.ElementAt <string>(0); string lastName = fullName.ElementAt <string>(1); bool wasEdited = false; foreach (var customer in _allCustomers) { if (customer.FirstName.ToLower() == firstName.ToLower() && customer.LastName.ToLower() == lastName.ToLower()) { var newCustomerInfo = EnterCustomerDetails(); wasEdited = customerManipulator.EditExistingCustomer(customer, newCustomerInfo); if (wasEdited) { Console.WriteLine("Customer info successfully updated."); Console.ReadKey(); } else { Console.WriteLine("Customer info could not be updated."); Console.ReadKey(); } } } }
public void TestEditMethod() { // Arrange (intialize variables) var oldCustomer = new Customer("Casey", "McDonough", CustomerType.Current); var newCustomer = new Customer("Gessenia", "Rivas", CustomerType.Potential); bool wasEdited = false; // Act (add oldCustomer to the list, then edit to newCustomer) customerTester.CreateCustomer(oldCustomer); wasEdited = customerTester.EditExistingCustomer(oldCustomer, newCustomer); // Assert (that the Edit method returns true) Assert.IsTrue(wasEdited, "Edit failed"); }