public FindView ( System.Web.Mvc.ControllerContext controllerContext, string viewName, string masterName, bool useCache ) : System.Web.Mvc.ViewEngineResult | ||
controllerContext | System.Web.Mvc.ControllerContext | |
viewName | string | |
masterName | string | |
useCache | bool | |
return | System.Web.Mvc.ViewEngineResult |
public void Should_Forward_FindView_To_Current_ModuleApplication_ViewEngineCollection() { // Arrange var mockEngines = new Mock<ViewEngineCollection>(); ViewEngineResult result = new ViewEngineResult(new[] { "foo", "bar", "baz" }); ControllerContext context = Mockery.CreateMockControllerContext(); string viewName = "Foo"; string masterName = "Bar"; mockEngines.Setup(e => e.FindView(context, viewName, masterName)) .Returns(result); SetupMockModuleApplication(context, mockEngines.Object); ModuleDelegatingViewEngine viewEngine = new ModuleDelegatingViewEngine(); // Act ViewEngineResult engineResult = viewEngine.FindView(context, viewName, masterName, true); // Assert mockEngines.Verify(e => e.FindView(context, viewName, masterName)); Assert.AreEqual("foo", engineResult.SearchedLocations.ElementAt(0)); Assert.AreEqual("bar", engineResult.SearchedLocations.ElementAt(1)); Assert.AreEqual("baz", engineResult.SearchedLocations.ElementAt(2)); }
public void Should_Return_Failed_ViewEngineResult_For_FindView_If_No_Current_Module_Application() { // Arrange ModuleDelegatingViewEngine viewEngine = new ModuleDelegatingViewEngine(); // Act ViewEngineResult engineResult = viewEngine.FindView(Mockery.CreateMockControllerContext(), "Foo", "Bar", true); // Assert Assert.IsNotNull(engineResult, "Expected that the ViewEngineResult would not be null"); Assert.IsNull(engineResult.View, "Expected that no view would be returned"); Assert.AreEqual(0, engineResult.SearchedLocations.Count(), "Expected that no searched locations would be specified"); }
public void Should_Track_ViewEngine_View_Pairs_On_FindView_And_Releases_View_Appropriately() { // Arrange var mockEngines = new Mock<ViewEngineCollection>(); var mockEngine = new Mock<IViewEngine>(); var mockView = new Mock<IView>(); ViewEngineResult result = new ViewEngineResult(mockView.Object, mockEngine.Object); ControllerContext context = Mockery.CreateMockControllerContext(); string viewName = "Foo"; string masterName = "Bar"; mockEngines.Setup(e => e.FindView(context, viewName, masterName)) .Returns(result); SetupMockModuleApplication(context, mockEngines.Object); ModuleDelegatingViewEngine viewEngine = new ModuleDelegatingViewEngine(); // Act ViewEngineResult engineResult = viewEngine.FindView(context, viewName, masterName, true); viewEngine.ReleaseView(context, engineResult.View); // Assert mockEngine.Verify(e => e.ReleaseView(context, mockView.Object)); }