コード例 #1
0
        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);
        }
コード例 #2
0
        public void CurrentCustomerReturnsCurrentCustomer()
        {
            CustomersController controller = GetCustomersControllerInitialized();
            Customer currentCustomer = new Customer();
            controller.CurrentCustomer = currentCustomer;

            Customer result = controller.CurrentCustomer;

            Assert.AreSame(currentCustomer, result);
        }
コード例 #3
0
 private Customer FindCustomer(Customer customer)
 {
     return Customers.Find(delegate(Customer match)
     {
         return match.Id == customer.Id;
     });
 }
コード例 #4
0
        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);
        }
コード例 #5
0
 public void UpdateCustomer(Customer customer)
 {
     Customer customerFound = FindCustomer(customer);
     customerFound.Approved = customer.Approved;
     customerFound.LastName = customer.LastName;
     customerFound.Name = customer.Name;
 }