public void TestMockHttpContext() { // Instantiate the view directly var view = new MockHttpContext(); // Set up the data that needs to be access by the view var mockHttpRequest = new Mock <HttpRequestBase>(MockBehavior.Loose); mockHttpRequest.Setup(m => m.IsAuthenticated).Returns(true); // Render it in an HtmlDocument var output = view.RenderAsHtml(new HttpContextBuilder().With(mockHttpRequest.Object).Build()); // Verify that it looks correct var element = output.GetElementbyId("user-authenticated"); Assert.IsNotNull(element); }
public void TestMockHttpContext() { // Instantiate the view directly var view = new MockHttpContext(); // Set up the data that needs to be access by the view var mockHttpRequest = new Mock<HttpRequestBase>(MockBehavior.Loose); mockHttpRequest.Setup(m => m.IsAuthenticated).Returns(true); // Render it in an HtmlDocument var output = view.RenderAsHtml(new HttpContextBuilder().With(mockHttpRequest.Object).Build()); // Verify that it looks correct var element = output.GetElementbyId("user-authenticated"); Assert.IsNotNull(element); }