public void ApproveCurrentCustomerApprovesCustomerAndUpdatesDataStoreAndRedirectsToSummary()
        {
            MockNavigationService navigationService = new MockNavigationService();
            List<Customer> customers = new List<Customer>();
            CustomersController controller = GetCustomersControllerInitialized(navigationService, customers);
            Customer customerInDataStore = new Customer(1000, "Enrique", "Gil", false);
            customers.Add(customerInDataStore);
            Customer customerToApprove = new Customer(1000, "Enrique", "Gil", false);
            controller.CurrentCustomer = customerToApprove;

            controller.ApproveCurrentCustomer();

            Assert.IsTrue(customerToApprove.Approved);
            Assert.IsTrue(customerInDataStore.Approved);
            Assert.IsTrue(navigationService.NavigateCalled);
            Assert.AreEqual(ViewNames.SummaryView, navigationService.View);
        }
        public void CurrentCustomerReturnsCurrentCustomer()
        {
            CustomersController controller = GetCustomersControllerInitialized();
            Customer currentCustomer = new Customer();
            controller.CurrentCustomer = currentCustomer;

            Customer result = controller.CurrentCustomer;

            Assert.AreSame(currentCustomer, result);
        }
 private Customer FindCustomer(Customer customer)
 {
     return Customers.Find(delegate(Customer match)
     {
         return match.Id == customer.Id;
     });
 }
        public void CurrentCustomerReturnsNextCustomerIfCurrentCustomerIsNull()
        {
            List<Customer> customers = new List<Customer>();
            CustomersController controller = GetCustomersControllerInitialized(customers);
            Customer nonApprovedCustomer = new Customer(1000, "Enrique", "Gil", false);
            customers.Add(nonApprovedCustomer);

            Customer result = controller.CurrentCustomer;

            Assert.AreSame(nonApprovedCustomer, result);
        }
 public void UpdateCustomer(Customer customer)
 {
     Customer customerFound = FindCustomer(customer);
     customerFound.Approved = customer.Approved;
     customerFound.LastName = customer.LastName;
     customerFound.Name = customer.Name;
 }