public void Index_Returns_New_ActionResult_In_The_Model() { var controller = new FakeHomeController(); Assert.IsNotNull(controller, "Controller was not created."); var result = controller.GetType().GetMethod("Index").Invoke(controller, null); Assert.IsInstanceOfType(result, typeof(ActionResult)); }
public void Foo_Action_Sets_Model_Correctly() { var controller = new FakeHomeController(); Assert.IsNotNull(controller, "Controller was not created."); var model = new Fakes.FakeHomeViewModel(); var result = controller.GetType().GetMethod("Foo").Invoke(controller, new List<object>() { model }.ToArray()); Assert.IsInstanceOfType(result, typeof(ActionResult)); Assert.AreEqual(model, controller.Model); }
public void Bar_Action_Sets_Model_Correctly() { var controller = new FakeHomeController(); Assert.IsNotNull(controller, "Controller was not created."); var result = controller.GetType().GetMethod("Bar").Invoke(controller, new List<object>() { "Hello Mvc!", 1 }.ToArray()); Assert.IsInstanceOfType(result, typeof(ActionResult)); Assert.AreEqual("Hello Mvc!", (controller.Model as FooBar).HelloMvc); Assert.AreEqual(1, (controller.Model as FooBar).Id); }
private IController CreateFakeHomeController() { context.RouteData.Values["controller"] = "fakehome"; var controller = new FakeHomeController(); return controller; }