public void ShouldPassViewNameToFindView() { var viewEngine = new Mock<IViewEngine>(); viewEngine.Setup(x => x.FindView(It.IsAny<ControllerContext>(), It.IsAny<ViewResultOptions>(), It.IsAny<string>())).Returns(new ViewEngineResult(true, null)); var result = new DummyViewResult("MyView", new ViewEngineCollection(viewEngine.Object)); var request = RequestBuilder.CreateRequest("MyController", "MyAction", null).BuildControllerContext(); result.Execute(request); viewEngine.Verify(x => x.FindView(request, It.IsAny<ViewResultOptions>(), "MyView")); }
public void ShouldThrowWhenViewNotFound() { var viewEngine = new Mock<IViewEngine>(); viewEngine.Setup(x => x.FindView(It.IsAny<ControllerContext>(), It.IsAny<ViewResultOptions>(), It.IsAny<string>())).Returns(new ViewEngineResult(false, new string[] { "ABC" })); var result = new DummyViewResult("MyView", new ViewEngineCollection(viewEngine.Object)); var request = RequestBuilder.CreateRequest("MyController", "MyAction", null).BuildControllerContext(); var ex = Assert.Throws<ViewNotFoundException>(() => result.Execute(request)); Assert.IsTrue(ex.SearchLocations.Contains("ABC")); Assert.AreEqual("MyView", ex.ViewName); }
public void ShouldPassViewNameToFindView() { var viewEngine = new Mock <IViewEngine>(); viewEngine.Setup(x => x.FindView(It.IsAny <ControllerContext>(), It.IsAny <ViewResultOptions>(), It.IsAny <string>())).Returns(new ViewEngineResult(true, null)); var result = new DummyViewResult("MyView", new ViewEngineCollection(viewEngine.Object)); var request = RequestBuilder.CreateRequest("MyController", "MyAction", null).BuildControllerContext(); result.Execute(request); viewEngine.Verify(x => x.FindView(request, It.IsAny <ViewResultOptions>(), "MyView")); }
public void ShouldThrowWhenViewNotFound() { var viewEngine = new Mock <IViewEngine>(); viewEngine.Setup(x => x.FindView(It.IsAny <ControllerContext>(), It.IsAny <ViewResultOptions>(), It.IsAny <string>())).Returns(new ViewEngineResult(false, new string[] { "ABC" })); var result = new DummyViewResult("MyView", new ViewEngineCollection(viewEngine.Object)); var request = RequestBuilder.CreateRequest("MyController", "MyAction", null).BuildControllerContext(); var ex = Assert.Throws <ViewNotFoundException>(() => result.Execute(request)); Assert.IsTrue(ex.SearchLocations.Contains("ABC")); Assert.AreEqual("MyView", ex.ViewName); }
public void ShouldSetModel() { var result = new DummyViewResult(null, "Hello world", new ViewEngineCollection()); Assert.AreEqual("Hello world", result.Options["Model"]); }
public void ShouldSetModel() { var result = new DummyViewResult(null, "Hello world", new ViewEngineCollection()); Assert.AreEqual("Hello world", result.Options["Model"]); }