public void ShouldRetrieveCustomerForEdit()
        {
            ICustomerAdapter adapter = Substitute.For<ICustomerAdapter>();
            CustomerData data = new CustomerData();
            adapter.GetCustomer(Arg.Any<string>()).Returns(data);

            using (ClassicController controller = new ClassicController(adapter))
            {
                string customerId = Guid.NewGuid().ToString("N");
                ActionResult result = controller.Edit(customerId);

                CustomerData model = ActionResultHelper.AssertViewWithModel<CustomerData>(result, controller.Views.Edit);

                adapter.Received().GetCustomer(customerId);

                Assert.AreSame(data, model, "The customer data was not passed to the view.");
            }
        }
        public void ShouldUpdateCustomerAndRedirectToIndex()
        {
            ICustomerAdapter adapter = Substitute.For<ICustomerAdapter>();
            using (ClassicController controller = new ClassicController(adapter))
            {
                CustomerData data = new CustomerData();
                ActionResult result = controller.Edit(data);

                adapter.Received().UpdateCustomer(data);

                ActionResultHelper.AssertRedirected(result, controller.Name, controller.ActionNames.Index);
            }
        }
        public void ShouldRedisplayViewWhenEditValidationFails()
        {
            ICustomerAdapter adapter = Substitute.For<ICustomerAdapter>();
            using (ClassicController controller = new ClassicController(adapter))
            {
                controller.ModelState.AddModelError("txtName", "You must provide a name for the customer.");

                CustomerData data = new CustomerData();
                ActionResult result = controller.Edit(data);

                CustomerData model = ActionResultHelper.AssertViewWithModel<CustomerData>(result, controller.Views.Edit);
                Assert.AreSame(data, model, "The model was not passed to the view.");
            }
        }