Ejemplo n.º 1
0
        public void ShouldBuildCreateViewWithNoModel()
        {
            ICustomerAdapter adapter = Substitute.For <ICustomerAdapter>();

            using (ClassicController controller = new ClassicController(adapter))
            {
                ActionResult result = controller.Create();

                ActionResultHelper.AssertView(result, controller.Views.Create);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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.");
            }
        }