Inheritance: Controller
Ejemplo n.º 1
0
        public void Getting_The_Main_View_Of_The_Controller_Should_Be_Impossible()
        {
            MockController controller = null;

            Given("we have a mock controller", () => controller = new MockController());

            When("we call its index action, i.e. we want to get its main view", () =>
            {
                try {
                    controller.Index();
                    false.ShouldBeTrue();
                } catch (InvalidOperationException) { }
            });

            Then("it should not be possible (as it is only a mock controller)");
        }
Ejemplo n.º 2
0
        public void Test_Mock_Session()
        {
            MockController controller = null;

            Given("we have a mock controller with a fake session", () =>
            {
                controller = new MockController();
                controller.SetFakeControllerContext();
            });

            When("we create a test session", () => controller.TestSession());

            Then("the test session should contain the right content", () =>
            {
                controller.HttpContext.Session["item2"].ShouldBe("This is used for testing a mock session.");
            });
        }