public void ShouldBuildCreateViewWithNoModel()
        {
            ICustomerAdapter adapter = Substitute.For<ICustomerAdapter>();
            using (ClassicController controller = new ClassicController(adapter))
            {
                ActionResult result = controller.Create();

                ActionResultHelper.AssertView(result, controller.Views.Create);
            }
        }
        public void ShouldCreateCustomerAndReturnToIndex()
        {
            ICustomerAdapter adapter = Substitute.For<ICustomerAdapter>();
            using (ClassicController controller = new ClassicController(adapter))
            {
                CustomerData data = new CustomerData();
                ActionResult result = controller.Create(data);

                adapter.Received().AddCustomer(data);

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

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

                CustomerData model = ActionResultHelper.AssertViewWithModel<CustomerData>(result, controller.Views.Create);
                Assert.AreSame(data, model, "The customer data was not set as the model.");
            }
        }