public void UpdateCustomer(Customer customer)
        {
            if (customer == null)
                throw new ArgumentNullException("customer");

            CustomersDataSet.CustomersDataTable customers = CustomersDataSet.Instance.Customers;
            CustomersDataSet.CustomersRow row = customers.FindById(customer.Id);
            if (row != null)
            {
                row.Name = customer.Name;
                row.Address = customer.Address;
                row.City = customer.City;
                row.State = customer.State;
                row.Zip = customer.Zip;
                row.AcceptChanges();
            }
        }
        public void UpdateCurrentCustomerUpdatesDataSource()
        {
            Customer updatedCustomer = new Customer();
            dataSource.UpdatedCustomerValue = null;
            dataSource.UpdateCustomerCalled = false;

            controller.UpdateCurrentCustomer(updatedCustomer);

            Assert.IsTrue(dataSource.UpdateCustomerCalled);
            Assert.AreSame(updatedCustomer, dataSource.UpdatedCustomerValue);
        }
        public void SetSelectedIndexChangedCurrentCustomer()
        {
            dataSource.GetCustomersReturnValue = new List<Customer>();
            dataSource.GetCustomersReturnValue.Add(new Customer("0", "Customer 0", "Address 0", "City 0", "State 0", "Zip 0"));
            dataSource.GetCustomersReturnValue.Add(new Customer("1", "Customer 1", "Address 1", "City 1", "State 1", "Zip 1"));
            dataSource.GetCustomersReturnValue.Add(new Customer("2", "Customer 2", "Address 2", "City 2", "State 2", "Zip 2"));
            Customer selectedCustomer3 = new Customer("3", "Customer 3", "Address 3", "City 3", "State 3", "Zip 3");
            dataSource.GetCustomersReturnValue.Add(selectedCustomer3);
            Customer selectedCustomer4 = new Customer("4", "Customer 4", "Address 4", "City 4", "State 4", "Zip 4");
            dataSource.GetCustomersReturnValue.Add(selectedCustomer4);

            controller.SetSelectedContactIndex(3);

            Assert.AreSame(selectedCustomer3, controller.CurrentCustomer);

            controller.SetSelectedContactIndex(4);

            Assert.AreSame(selectedCustomer4, controller.CurrentCustomer);
        }
 public void ShowCustomer(Customer customer)
 {
     CustomerDataSource.DataSource = customer;
 }
 public void UpdateCurrentCustomer(Customer customer)
 {
     UpdateCustomerCalled = true;
     UpdatedCustomer = customer;
 }
 public void UpdateCustomer(Customer customer)
 {
     UpdateCustomerCalled = true;
     UpdatedCustomerValue = customer;
 }
 public void UpdateCurrentCustomer(Customer customer)
 {
     _datasource.UpdateCustomer(customer);
     customer = null;
 }
 public void ShowCustomer(Customer customer)
 {
     CustomerLoaded = customer;
 }
 public void FireSaveClicked(Customer customer)
 {
     if (SaveClicked != null)
     {
         SaveClicked(this, new DataEventArgs<Customer>(customer));
     }
 }
        public void WhenSaveIsClickedViewModeIsReadOnlyAndCustomerInfoIsUpdatedInController()
        {
            presenter.OnViewLoaded();
            controller.CurrentCustomer = new Customer("1", "Customer 1", "Address 1", "City 1", "WA", "11111");
            Customer editedCustomer = new Customer("1", "Customer 1 Modified", "Address 1 Modified", "City 2", "OR", "22222");

            view.SetViewModeCalled = false;
            view.SetViewModeReadOnly = false;
            view.FireSaveClicked(editedCustomer);

            Assert.IsTrue(controller.UpdateCustomerCalled);
            Assert.IsTrue(view.SetViewModeCalled);
            Assert.IsTrue(view.SetViewModeReadOnly);

            Assert.AreNotSame(editedCustomer, controller.CurrentCustomer);
            Assert.AreSame(editedCustomer, controller.UpdatedCustomer);

            Assert.AreEqual("Customer 1 Modified", controller.UpdatedCustomer.Name);
            Assert.AreEqual("Address 1 Modified", controller.UpdatedCustomer.Address);
            Assert.AreEqual("City 2", controller.UpdatedCustomer.City);
            Assert.AreEqual("OR", controller.UpdatedCustomer.State);
            Assert.AreEqual("22222", controller.UpdatedCustomer.Zip);
        }