Address PR comments

- removed `isMainPage` parameter to `GetPage()` and `FindPage()`
This commit is contained in:
Doug Bunting 2015-11-18 15:57:18 -08:00
parent 3be6167aa0
commit 95b3d2c1dd
8 changed files with 109 additions and 149 deletions

View File

@ -16,10 +16,9 @@ namespace Microsoft.AspNet.Mvc.Razor
/// </summary>
/// <param name="context">The <see cref="ActionContext"/>.</param>
/// <param name="pageName">The name of the page.</param>
/// <param name="isMainPage">Determines if the page being found is the main page for an action.</param>
/// <returns>The <see cref="RazorPageResult"/> of locating the page.</returns>
/// <remarks><seealso cref="IViewEngine.FindView"/>.</remarks>
RazorPageResult FindPage(ActionContext context, string pageName, bool isMainPage);
RazorPageResult FindPage(ActionContext context, string pageName);
/// <summary>
/// Gets the page with the given <paramref name="pagePath"/>, relative to <paramref name="executingFilePath"/>
@ -27,10 +26,9 @@ namespace Microsoft.AspNet.Mvc.Razor
/// </summary>
/// <param name="executingFilePath">The absolute path to the currently-executing page, if any.</param>
/// <param name="pagePath">The path to the page.</param>
/// <param name="isMainPage">Determines if the page being found is the main page for an action.</param>
/// <returns>The <see cref="RazorPageResult"/> of locating the page.</returns>
/// <remarks><seealso cref="IViewEngine.GetView"/>.</remarks>
RazorPageResult GetPage(string executingFilePath, string pagePath, bool isMainPage);
RazorPageResult GetPage(string executingFilePath, string pagePath);
/// <summary>
/// Converts the given <paramref name="pagePath"/> to be absolute, relative to

View File

@ -257,11 +257,11 @@ namespace Microsoft.AspNet.Mvc.Razor
private IRazorPage GetLayoutPage(ViewContext context, string executingFilePath, string layoutPath)
{
var layoutPageResult = _viewEngine.GetPage(executingFilePath, layoutPath, isMainPage: false);
var layoutPageResult = _viewEngine.GetPage(executingFilePath, layoutPath);
var originalLocations = layoutPageResult.SearchedLocations;
if (layoutPageResult.Page == null)
{
layoutPageResult = _viewEngine.FindPage(context, layoutPath, isMainPage: false);
layoutPageResult = _viewEngine.FindPage(context, layoutPath);
}
if (layoutPageResult.Page == null)

View File

@ -175,7 +175,7 @@ namespace Microsoft.AspNet.Mvc.Razor
}
/// <inheritdoc />
public RazorPageResult FindPage(ActionContext context, string pageName, bool isMainPage)
public RazorPageResult FindPage(ActionContext context, string pageName)
{
if (context == null)
{
@ -193,7 +193,7 @@ namespace Microsoft.AspNet.Mvc.Razor
return new RazorPageResult(pageName, Enumerable.Empty<string>());
}
var cacheResult = LocatePageFromViewLocations(context, pageName, isMainPage);
var cacheResult = LocatePageFromViewLocations(context, pageName, isMainPage: false);
if (cacheResult.Success)
{
var razorPage = cacheResult.ViewEntry.PageFactory();
@ -206,7 +206,7 @@ namespace Microsoft.AspNet.Mvc.Razor
}
/// <inheritdoc />
public RazorPageResult GetPage(string executingFilePath, string pagePath, bool isMainPage)
public RazorPageResult GetPage(string executingFilePath, string pagePath)
{
if (string.IsNullOrEmpty(pagePath))
{
@ -219,7 +219,7 @@ namespace Microsoft.AspNet.Mvc.Razor
return new RazorPageResult(pagePath, Enumerable.Empty<string>());
}
var cacheResult = LocatePageFromPath(executingFilePath, pagePath, isMainPage);
var cacheResult = LocatePageFromPath(executingFilePath, pagePath, isMainPage: false);
if (cacheResult.Success)
{
var razorPage = cacheResult.ViewEntry.PageFactory();

View File

@ -77,9 +77,9 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
throw new ArgumentNullException(nameof(context));
}
var viewEngine = ViewEngine ?? ResolveViewEngine(context);
var viewContext = context.ViewContext;
var viewData = ViewData ?? context.ViewData;
var viewEngine = ViewEngine ?? ResolveViewEngine(context);
var isNullOrEmptyViewName = string.IsNullOrEmpty(ViewName);
ViewEngineResult result = null;

View File

@ -40,9 +40,9 @@ namespace Microsoft.AspNet.Mvc.ViewEngines
// Do not allocate in the common cases: ViewEngines contains one entry or initial attempt is successful.
IEnumerable<string> searchedLocations = null;
List<string> searchedList = null;
for (var index = 0; index < ViewEngines.Count; index++)
for (var i = 0; i < ViewEngines.Count; i++)
{
var result = ViewEngines[index].FindView(context, viewName, isMainPage);
var result = ViewEngines[i].FindView(context, viewName, isMainPage);
if (result.Success)
{
return result;
@ -80,9 +80,9 @@ namespace Microsoft.AspNet.Mvc.ViewEngines
// Do not allocate in the common cases: ViewEngines contains one entry or initial attempt is successful.
IEnumerable<string> searchedLocations = null;
List<string> searchedList = null;
for (var index = 0; index < ViewEngines.Count; index++)
for (var i = 0; i < ViewEngines.Count; i++)
{
var result = ViewEngines[index].GetView(executingFilePath, viewPath, isMainPage);
var result = ViewEngines[i].GetView(executingFilePath, viewPath, isMainPage);
if (result.Success)
{
return result;

View File

@ -112,7 +112,6 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
var viewEngineResult = _viewEngine.GetView(_viewContext.ExecutingFilePath, viewName, isMainPage: false);
if (!viewEngineResult.Success)
{
// Success here is more common than with GetView() but GetView() is less expensive.
var fullViewName = modeViewPath + "/" + viewName;
viewEngineResult = _viewEngine.FindView(_viewContext, fullViewName, isMainPage: false);
}

View File

@ -270,78 +270,44 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
Assert.False(result.Success);
}
[Fact]
public void FindView_FailsButSearchesCorrectLocations_WithAreas()
[Theory]
[InlineData(true)]
[InlineData(false)]
public void FindView_FailsButSearchesCorrectLocationsWithAreas(bool isMainPage)
{
// Arrange
var viewEngine = CreateViewEngine();
var context = GetActionContext(_areaTestContext);
// Act
var result = viewEngine.FindView(context, "partial", isMainPage: false);
// Assert
Assert.False(result.Success);
Assert.Equal(new[]
{
"/Areas/foo/Views/bar/partial.cshtml",
"/Areas/foo/Views/Shared/partial.cshtml",
"/Views/Shared/partial.cshtml",
}, result.SearchedLocations);
}
[Fact]
public void FindView_FailsButSearchesCorrectLocations_WithoutAreas()
{
// Arrange
var viewEngine = CreateViewEngine();
var context = GetActionContext(_controllerTestContext);
// Act
var result = viewEngine.FindView(context, "partialNoArea", isMainPage: false);
var result = viewEngine.FindView(context, "viewName", isMainPage);
// Assert
Assert.False(result.Success);
Assert.Equal(new[] {
"/Views/bar/partialNoArea.cshtml",
"/Views/Shared/partialNoArea.cshtml",
}, result.SearchedLocations);
}
[Fact]
public void FindView_IsMainPage_FailsButSearchesCorrectLocationsWithAreas()
{
// Arrange
var viewEngine = CreateViewEngine();
var context = GetActionContext(_areaTestContext);
// Act
var result = viewEngine.FindView(context, "full", isMainPage: true);
// Assert
Assert.False(result.Success);
Assert.Equal(new[] {
"/Areas/foo/Views/bar/full.cshtml",
"/Areas/foo/Views/Shared/full.cshtml",
"/Areas/foo/Views/bar/viewName.cshtml",
"/Areas/foo/Views/Shared/viewName.cshtml",
"/Views/Shared/full.cshtml",
}, result.SearchedLocations);
}
[Fact]
public void FindView_IsMainPage_FailsButSearchesCorrectLocationsWithoutAreas()
[Theory]
[InlineData(true)]
[InlineData(false)]
public void FindView_FailsButSearchesCorrectLocationsWithoutAreas(bool isMainPage)
{
// Arrange
var viewEngine = CreateViewEngine();
var context = GetActionContext(_controllerTestContext);
// Act
var result = viewEngine.FindView(context, "fullNoArea", isMainPage: true);
var result = viewEngine.FindView(context, "viewName", isMainPage);
// Assert
Assert.False(result.Success);
Assert.Equal(new[] {
"/Views/bar/fullNoArea.cshtml",
"/Views/Shared/fullNoArea.cshtml",
"/Views/bar/viewName.cshtml",
"/Views/Shared/viewName.cshtml",
}, result.SearchedLocations);
}
@ -377,11 +343,14 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
var view = Assert.IsType<RazorView>(result.View);
Assert.Equal("test-view", result.ViewName);
Assert.Same(page, view.RazorPage);
// ViewStartPages is not empty as it is in FindView_ReturnsRazorView_IfLookupWasSuccessful() despite
// (faked) existence of the view start files in both tests.
Assert.Equal(new[] { viewStart1, viewStart2 }, view.ViewStartPages);
}
[Fact]
public void FindView_IsMainPage_UsesViewLocationFormat_IfRouteDoesNotContainArea()
public void FindView_UsesViewLocationFormat_IfRouteDoesNotContainArea()
{
// Arrange
var pageFactory = new Mock<IRazorPageFactoryProvider>();
@ -409,7 +378,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
}
[Fact]
public void FindView_IsMainPage_UsesAreaViewLocationFormat_IfRouteContainsArea()
public void FindView_UsesAreaViewLocationFormat_IfRouteContainsArea()
{
// Arrange
var viewName = "test-view2";
@ -440,7 +409,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[Theory]
[InlineData("Test-View.cshtml")]
[InlineData("/Home/Test-View.cshtml")]
public void GetView_IsMainPage_DoesNotUseViewLocationFormat_WithRelativePath_IfRouteDoesNotContainArea(string viewName)
public void GetView_DoesNotUseViewLocationFormat_WithRelativePath_IfRouteDoesNotContainArea(string viewName)
{
// Arrange
var expectedViewName = "/Home/Test-View.cshtml";
@ -466,7 +435,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[Theory]
[InlineData("Test-View.cshtml")]
[InlineData("/Home/Test-View.cshtml")]
public void GetView_IsMainPage_DoesNotUseViewLocationFormat_WithRelativePath_IfRouteContainArea(string viewName)
public void GetView_DoesNotUseViewLocationFormat_WithRelativePath_IfRouteContainArea(string viewName)
{
// Arrange
var expectedViewName = "/Home/Test-View.cshtml";
@ -495,7 +464,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[InlineData("/Home/Test-View.CSHTML")]
[InlineData("~/Home/Test-View.cshtml")]
[InlineData("~/SHARED/TEST-VIEW.CSHTML")]
public void GetView_IsMainPage_UsesGivenPath_WithAppRelativePath(string viewName)
public void GetView_UsesGivenPath_WithAppRelativePath(string viewName)
{
// Arrange
var pageFactory = new Mock<IRazorPageFactoryProvider>();
@ -522,7 +491,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[InlineData("Test-View.CSHTML")]
[InlineData("PATH/TEST-VIEW.CSHTML")]
[InlineData("Path1/Path2/Test-View.cshtml")]
public void GetView_IsMainPage_ResolvesRelativeToCurrentPage_WithRelativePath(string viewName)
public void GetView_ResolvesRelativeToCurrentPage_WithRelativePath(string viewName)
{
// Arrange
var expectedViewName = $"/Home/{ viewName }";
@ -550,7 +519,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[InlineData("Test-View.CSHTML")]
[InlineData("PATH/TEST-VIEW.CSHTML")]
[InlineData("Path1/Path2/Test-View.cshtml")]
public void GetView_IsMainPage_ResolvesRelativeToAppRoot_WithRelativePath_IfNoPageExecuting(string viewName)
public void GetView_ResolvesRelativeToAppRoot_WithRelativePath_IfNoPageExecuting(string viewName)
{
// Arrange
var expectedViewName = $"/{ viewName }";
@ -577,7 +546,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[Theory]
[MemberData(nameof(ViewLocationExpanderTestData))]
public void FindView_IsMainPage_UsesViewLocationExpandersToLocateViews(
public void FindView_UsesViewLocationExpandersToLocateViews(
IDictionary<string, object> routeValues,
IEnumerable<string> expectedSeeds)
{
@ -639,7 +608,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
}
[Fact]
public void FindView_IsMainPage_CachesValuesIfViewWasFound()
public void FindView_CachesValuesIfViewWasFound()
{
// Arrange
var page = Mock.Of<IRazorPage>();
@ -680,7 +649,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
}
[Fact]
public void FindView_IsMainPage_InvokesPageFactoryIfChangeTokenExpired()
public void FindView_InvokesPageFactoryIfChangeTokenExpired()
{
// Arrange
var page1 = Mock.Of<IRazorPage>();
@ -727,7 +696,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
}
[Fact]
public void FindView_IsMainPage_InvokesPageFactoryIfViewStartExpirationTokensHaveExpired()
public void FindView_InvokesPageFactoryIfViewStartExpirationTokensHaveExpired()
{
// Arrange
var page1 = Mock.Of<IRazorPage>();
@ -784,7 +753,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
// This test validates an important perf scenario of RazorViewEngine not constructing
// multiple strings for views that do not exist in the file system on a per-request basis.
[Fact]
public void FindView_IsMainPage_DoesNotInvokeViewLocationExpanders_IfChangeTokenHasNotExpired()
public void FindView_DoesNotInvokeViewLocationExpanders_IfChangeTokenHasNotExpired()
{
// Arrange
var pageFactory = Mock.Of<IRazorPageFactoryProvider>();
@ -837,7 +806,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
}
[Fact]
public void FindView_IsMainPage_InvokesViewLocationExpanders_IfChangeTokenExpires()
public void FindView_InvokesViewLocationExpanders_IfChangeTokenExpires()
{
// Arrange
var cancellationTokenSource = new CancellationTokenSource();
@ -902,14 +871,14 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[Theory]
[MemberData(nameof(AbsoluteViewPathData))]
public void FindPage_IsMainPage_WithFullPath_ReturnsNotFound(string viewName)
public void FindPage_WithFullPath_ReturnsNotFound(string viewName)
{
// Arrange
var viewEngine = CreateSuccessfulViewEngine();
var context = GetActionContext(_controllerTestContext);
// Act
var result = viewEngine.FindPage(context, viewName, isMainPage: true);
var result = viewEngine.FindPage(context, viewName);
// Assert
Assert.Null(result.Page);
@ -917,7 +886,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[Theory]
[MemberData(nameof(AbsoluteViewPathData))]
public void FindPage_IsMainPage_WithFullPathAndCshtmlEnding_ReturnsNotFound(string viewName)
public void FindPage_WithFullPathAndCshtmlEnding_ReturnsNotFound(string viewName)
{
// Arrange
var viewEngine = CreateSuccessfulViewEngine();
@ -925,38 +894,34 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
viewName += ".cshtml";
// Act
var result = viewEngine.FindPage(context, viewName, isMainPage: true);
var result = viewEngine.FindPage(context, viewName);
// Assert
Assert.Null(result.Page);
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void FindPage_WithRelativePath_ReturnsNotFound(bool isMainPage)
[Fact]
public void FindPage_WithRelativePath_ReturnsNotFound()
{
// Arrange
var viewEngine = CreateSuccessfulViewEngine();
var context = GetActionContext(_controllerTestContext);
// Act
var result = viewEngine.FindPage(context, "View.cshtml", isMainPage);
var result = viewEngine.FindPage(context, "View.cshtml");
// Assert
Assert.Null(result.Page);
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void GetPage_WithViewName_ReturnsNotFound(bool isMainPage)
[Fact]
public void GetPage_WithViewName_ReturnsNotFound()
{
// Arrange
var viewEngine = CreateSuccessfulViewEngine();
// Act
var result = viewEngine.GetPage("~/Home/View1.cshtml", "View2", isMainPage);
var result = viewEngine.GetPage("~/Home/View1.cshtml", "View2");
// Assert
Assert.Null(result.Page);
@ -973,7 +938,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
// Act & Assert
ExceptionAssert.ThrowsArgumentNullOrEmpty(
() => viewEngine.FindPage(context, pageName, isMainPage: false),
() => viewEngine.FindPage(context, pageName),
"pageName");
}
@ -1021,7 +986,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
var context = GetActionContext(routeValues);
// Act
var result = viewEngine.FindPage(context, "layout", isMainPage: false);
var result = viewEngine.FindPage(context, "layout");
// Assert
Assert.Equal("layout", result.Name);
@ -1031,10 +996,8 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
expander.Verify();
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void FindPage_ReturnsSearchedLocationsIfPageCannotBeFound(bool isMainPage)
[Fact]
public void FindPage_ReturnsSearchedLocationsIfPageCannotBeFound()
{
// Arrange
var expected = new[]
@ -1047,7 +1010,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
var context = GetActionContext(_controllerTestContext);
// Act
var result = viewEngine.FindPage(context, "layout", isMainPage);
var result = viewEngine.FindPage(context, "layout");
// Assert
Assert.Equal("layout", result.Name);
@ -1088,7 +1051,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
isAttributeRouted);
// Act
var result = viewEngine.FindPage(context, "details", isMainPage: false);
var result = viewEngine.FindPage(context, "details");
// Assert
Assert.Equal("details", result.Name);
@ -1127,7 +1090,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
isAttributeRouted);
// Act
var result = viewEngine.FindPage(context, "foo", isMainPage: false);
var result = viewEngine.FindPage(context, "foo");
// Assert
Assert.Equal("foo", result.Name);
@ -1168,7 +1131,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
isAttributeRouted);
// Act
var result = viewEngine.FindPage(context, "foo", isMainPage: false);
var result = viewEngine.FindPage(context, "foo");
// Assert
Assert.Equal("foo", result.Name);
@ -1200,7 +1163,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
isAttributeRouted);
// Act
var result = viewEngine.FindPage(context, "bar", isMainPage: false);
var result = viewEngine.FindPage(context, "bar");
// Assert
Assert.Equal("bar", result.Name);
@ -1214,7 +1177,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[InlineData("/Home/Test-View.CSHTML")]
[InlineData("~/Home/Test-View.cshtml")]
[InlineData("~/SHARED/TEST-VIEW.CSHTML")]
public void GetPage_IsMainPage_UsesGivenPath_WithAppRelativePath(string pageName)
public void GetPage_UsesGivenPath_WithAppRelativePath(string pageName)
{
// Arrange
var pageFactory = new Mock<IRazorPageFactoryProvider>();
@ -1228,7 +1191,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
GetOptionsAccessor());
// Act
var result = viewEngine.GetPage("~/Another/Place.cshtml", pagePath: pageName, isMainPage: true);
var result = viewEngine.GetPage("~/Another/Place.cshtml", pagePath: pageName);
// Assert
Assert.Same(page, result.Page);
@ -1241,7 +1204,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[InlineData("Test-View.CSHTML")]
[InlineData("PATH/TEST-VIEW.CSHTML")]
[InlineData("Path1/Path2/Test-View.cshtml")]
public void GetPage_IsMainPage_ResolvesRelativeToCurrentPage_WithRelativePath(string pageName)
public void GetPage_ResolvesRelativeToCurrentPage_WithRelativePath(string pageName)
{
// Arrange
var expectedPageName = $"/Home/{ pageName }";
@ -1256,7 +1219,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
GetOptionsAccessor());
// Act
var result = viewEngine.GetPage("/Home/Page.cshtml", pageName, isMainPage: true);
var result = viewEngine.GetPage("/Home/Page.cshtml", pageName);
// Assert
Assert.Same(page, result.Page);
@ -1269,7 +1232,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[InlineData("Test-View.CSHTML")]
[InlineData("PATH/TEST-VIEW.CSHTML")]
[InlineData("Path1/Path2/Test-View.cshtml")]
public void GetPage_IsMainPage_ResolvesRelativeToAppRoot_WithRelativePath_IfNoPageExecuting(string pageName)
public void GetPage_ResolvesRelativeToAppRoot_WithRelativePath_IfNoPageExecuting(string pageName)
{
// Arrange
var expectedPageName = $"/{ pageName }";
@ -1284,7 +1247,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
GetOptionsAccessor());
// Act
var result = viewEngine.GetPage(executingFilePath: null, pagePath: pageName, isMainPage: true);
var result = viewEngine.GetPage(executingFilePath: null, pagePath: pageName);
// Assert
Assert.Same(page, result.Page);
@ -1322,7 +1285,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[InlineData("/Home/Index.cshtml", "~/Page")]
[InlineData("/Home/Index.cshtml", "/Folder/Page.cshtml")]
[InlineData("/Home/Index.cshtml", "~/Folder1/Folder2/Page.rzr")]
public void GetAbsolutePath_ReturnsPageUnchanged_IfAppRelative(string executingFilePath, string pagePath)
public void GetAbsolutePath_ReturnsPagePathUnchanged_IfAppRelative(string executingFilePath, string pagePath)
{
// Arrange
var viewEngine = CreateViewEngine();

View File

@ -136,7 +136,7 @@ namespace Microsoft.AspNet.Mvc.Razor
.Setup(p => p.GetAbsolutePath("_ViewStart", LayoutPath))
.Returns(LayoutPath);
viewEngine
.Setup(v => v.GetPage(pagePath, LayoutPath, /*isMainPage*/ false))
.Setup(v => v.GetPage(pagePath, LayoutPath))
.Returns(new RazorPageResult(LayoutPath, layout));
var view = new RazorView(
viewEngine.Object,
@ -208,7 +208,7 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(v => v.GetPage(/*executingFilePath*/ null, LayoutPath, /*isMainPage*/ false))
.Setup(v => v.GetPage(/*executingFilePath*/ null, LayoutPath))
.Returns(new RazorPageResult(LayoutPath, layout));
var view = new RazorView(
@ -384,11 +384,11 @@ namespace Microsoft.AspNet.Mvc.Razor
new HtmlTestEncoder());
var viewContext = CreateViewContext(view);
viewEngine
.Setup(v => v.GetPage(/*executingFilePath*/ null, layoutPath, /*isMainPage*/ false))
.Setup(v => v.GetPage(/*executingFilePath*/ null, layoutPath))
.Returns(new RazorPageResult(layoutPath, new[] { "path1", "path2" }))
.Verifiable();
viewEngine
.Setup(v => v.FindPage(viewContext, layoutPath, /*isMainPage*/ false))
.Setup(v => v.FindPage(viewContext, layoutPath))
.Returns(new RazorPageResult(layoutPath, Enumerable.Empty<string>()))
.Verifiable();
@ -426,11 +426,11 @@ namespace Microsoft.AspNet.Mvc.Razor
new HtmlTestEncoder());
var viewContext = CreateViewContext(view);
viewEngine
.Setup(v => v.GetPage(/*executingFilePath*/ null, layoutPath, /*isMainPage*/ false))
.Setup(v => v.GetPage(/*executingFilePath*/ null, layoutPath))
.Returns(new RazorPageResult(layoutPath, Enumerable.Empty<string>()))
.Verifiable();
viewEngine
.Setup(v => v.FindPage(viewContext, layoutPath, /*isMainPage*/ false))
.Setup(v => v.FindPage(viewContext, layoutPath))
.Returns(new RazorPageResult(layoutPath, new[] { "path1", "path2" }))
.Verifiable();
@ -470,11 +470,11 @@ namespace Microsoft.AspNet.Mvc.Razor
new HtmlTestEncoder());
var viewContext = CreateViewContext(view);
viewEngine
.Setup(v => v.GetPage(/*executingFilePath*/ null, layoutPath, /*isMainPage*/ false))
.Setup(v => v.GetPage(/*executingFilePath*/ null, layoutPath))
.Returns(new RazorPageResult(layoutPath, new[] { "path1", "path2" }))
.Verifiable();
viewEngine
.Setup(v => v.FindPage(viewContext, layoutPath, /*isMainPage*/ false))
.Setup(v => v.FindPage(viewContext, layoutPath))
.Returns(new RazorPageResult(layoutPath, new[] { "path3", "path4" }))
.Verifiable();
@ -533,7 +533,7 @@ namespace Microsoft.AspNet.Mvc.Razor
.Verifiable();
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(v => v.GetPage(/*executingFilePath*/ null, LayoutPath, /*isMainPage*/ false))
.Setup(v => v.GetPage(/*executingFilePath*/ null, LayoutPath))
.Returns(new RazorPageResult(LayoutPath, layout))
.Verifiable();
@ -574,7 +574,7 @@ namespace Microsoft.AspNet.Mvc.Razor
};
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(v => v.GetPage(/*executingFilePath*/ null, LayoutPath, /*isMainPage*/ false))
.Setup(v => v.GetPage(/*executingFilePath*/ null, LayoutPath))
.Returns(new RazorPageResult(LayoutPath, layout));
var view = new RazorView(
@ -636,10 +636,10 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(v => v.GetPage(/*executingFilePath*/ null, "~/Shared/Layout1.cshtml", /*isMainPage*/ false))
.Setup(v => v.GetPage(/*executingFilePath*/ null, "~/Shared/Layout1.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout1.cshtml", nestedLayout));
viewEngine
.Setup(v => v.GetPage("/Shared/Layout1.cshtml", "~/Shared/Layout2.cshtml", /*isMainPage*/ false))
.Setup(v => v.GetPage("/Shared/Layout1.cshtml", "~/Shared/Layout2.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout2.cshtml", baseLayout));
var view = new RazorView(
@ -698,16 +698,16 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(v => v.GetPage(/*executingFilePath*/ null, "NestedLayout", /*isMainPage*/ false))
.Setup(v => v.GetPage(/*executingFilePath*/ null, "NestedLayout"))
.Returns(new RazorPageResult("NestedLayout", Enumerable.Empty<string>()));
viewEngine
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "NestedLayout", /*isMainPage*/ false))
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "NestedLayout"))
.Returns(new RazorPageResult("NestedLayout", nestedLayout));
viewEngine
.Setup(v => v.GetPage("NestedLayout", "Layout", /*isMainPage*/ false))
.Setup(v => v.GetPage("NestedLayout", "Layout"))
.Returns(new RazorPageResult("Layout", Enumerable.Empty<string>()));
viewEngine
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "Layout", /*isMainPage*/ false))
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "Layout"))
.Returns(new RazorPageResult("Layout", baseLayout));
var view = new RazorView(
@ -766,10 +766,10 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(v => v.GetPage(/*executingFilePath*/ null, "~/Shared/Layout1.cshtml", /*isMainPage*/ false))
.Setup(v => v.GetPage(/*executingFilePath*/ null, "~/Shared/Layout1.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout1.cshtml", nestedLayout));
viewEngine
.Setup(v => v.GetPage("/Shared/Layout1.cshtml", "~/Shared/Layout2.cshtml", /*isMainPage*/ false))
.Setup(v => v.GetPage("/Shared/Layout1.cshtml", "~/Shared/Layout2.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout2.cshtml", baseLayout));
var view = new RazorView(
@ -833,10 +833,10 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(p => p.GetPage("Page", "~/Shared/Layout1.cshtml", /*isMainPage*/ false))
.Setup(p => p.GetPage("Page", "~/Shared/Layout1.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout1.cshtml", nestedLayout));
viewEngine
.Setup(p => p.GetPage("/Shared/Layout1.cshtml", "~/Shared/Layout2.cshtml", /*isMainPage*/ false))
.Setup(p => p.GetPage("/Shared/Layout1.cshtml", "~/Shared/Layout2.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout2.cshtml", baseLayout));
var view = new RazorView(
@ -869,7 +869,7 @@ namespace Microsoft.AspNet.Mvc.Razor
};
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(p => p.GetPage(/*executingFilePath*/ null, LayoutPath, /*isMainPage*/ false))
.Setup(p => p.GetPage(/*executingFilePath*/ null, LayoutPath))
.Returns(new RazorPageResult(LayoutPath, layout));
var view = new RazorView(
@ -932,10 +932,10 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(p => p.GetPage(/*executingFilePath*/ null, "~/Shared/Layout1.cshtml", /*isMainPage*/ false))
.Setup(p => p.GetPage(/*executingFilePath*/ null, "~/Shared/Layout1.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout1.cshtml", layout1));
viewEngine
.Setup(p => p.GetPage("~/Shared/Layout1.cshtml", "~/Shared/Layout2.cshtml", /*isMainPage*/ false))
.Setup(p => p.GetPage("~/Shared/Layout1.cshtml", "~/Shared/Layout2.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout2.cshtml", layout2));
var view = new RazorView(
@ -1005,10 +1005,10 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(p => p.GetPage("~/Shared/Page.cshtml", "Layout1.cshtml", /*isMainPage*/ false))
.Setup(p => p.GetPage("~/Shared/Page.cshtml", "Layout1.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout1.cshtml", layout1));
viewEngine
.Setup(p => p.GetPage("~/Shared/Layout1.cshtml", "Layout2.cshtml", /*isMainPage*/ false))
.Setup(p => p.GetPage("~/Shared/Layout1.cshtml", "Layout2.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout2.cshtml", layout2));
var view = new RazorView(
@ -1045,10 +1045,10 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(p => p.GetPage(It.IsAny<string>(), "_Layout", /*isMainPage*/ false))
.Setup(p => p.GetPage(It.IsAny<string>(), "_Layout"))
.Returns(new RazorPageResult("_Layout", Enumerable.Empty<string>()));
viewEngine
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "_Layout", /*isMainPage*/ false))
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "_Layout"))
.Returns(new RazorPageResult("_Layout", layout));
var view = new RazorView(
@ -1092,16 +1092,16 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(p => p.GetPage(It.IsAny<string>(), "_Layout", /*isMainPage*/ false))
.Setup(p => p.GetPage(It.IsAny<string>(), "_Layout"))
.Returns(new RazorPageResult("_Layout1", Enumerable.Empty<string>()));
viewEngine
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "_Layout", /*isMainPage*/ false))
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "_Layout"))
.Returns(new RazorPageResult("_Layout", layout1));
viewEngine
.Setup(p => p.GetPage("Shared/_Layout.cshtml", "_Layout2", /*isMainPage*/ false))
.Setup(p => p.GetPage("Shared/_Layout.cshtml", "_Layout2"))
.Returns(new RazorPageResult("_Layout2", Enumerable.Empty<string>()));
viewEngine
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "_Layout2", /*isMainPage*/ false))
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "_Layout2"))
.Returns(new RazorPageResult("_Layout2", layout2));
var view = new RazorView(
@ -1167,10 +1167,10 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(p => p.GetPage(/*executingFilePath*/ null, "~/Shared/Layout1.cshtml", /*isMainPage*/ false))
.Setup(p => p.GetPage(/*executingFilePath*/ null, "~/Shared/Layout1.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout1.cshtml", nestedLayout));
viewEngine
.Setup(p => p.GetPage("~/Shared/Layout1.cshtml", "~/Shared/Layout2.cshtml", /*isMainPage*/ false))
.Setup(p => p.GetPage("~/Shared/Layout1.cshtml", "~/Shared/Layout2.cshtml"))
.Returns(new RazorPageResult("~/Shared/Layout2.cshtml", baseLayout));
var view = new RazorView(
@ -1224,10 +1224,10 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(p => p.GetPage(/*executingFilePath*/ null, "layout-1", /*isMainPage*/ false))
.Setup(p => p.GetPage(/*executingFilePath*/ null, "layout-1"))
.Returns(new RazorPageResult("layout-1", Enumerable.Empty<string>()));
viewEngine
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "layout-1", /*isMainPage*/ false))
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "layout-1"))
.Returns(new RazorPageResult("layout-1", layout1));
var view = new RazorView(
@ -1278,10 +1278,10 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(p => p.GetPage(/*executingFilePath*/ null, "layout-1", /*isMainPage*/ false))
.Setup(p => p.GetPage(/*executingFilePath*/ null, "layout-1"))
.Returns(new RazorPageResult("layout-1", Enumerable.Empty<string>()));
viewEngine
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "layout-1", /*isMainPage*/ false))
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "layout-1"))
.Returns(new RazorPageResult("layout-1", layout1));
var view = new RazorView(
@ -1357,7 +1357,7 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
var layoutPath = "~/Shared/Layout1.cshtml";
viewEngine
.Setup(p => p.GetPage("/Views/TestPath/Test.cshtml", layoutPath, /*isMainPage*/ false))
.Setup(p => p.GetPage("/Views/TestPath/Test.cshtml", layoutPath))
.Returns(new RazorPageResult(layoutPath, layoutPage));
var view = new RazorView(
@ -1434,10 +1434,10 @@ namespace Microsoft.AspNet.Mvc.Razor
var viewEngine = new Mock<IRazorViewEngine>(MockBehavior.Strict);
viewEngine
.Setup(p => p.GetPage("/MyPage.cshtml", "Layout", /*isMainPage*/ false))
.Setup(p => p.GetPage("/MyPage.cshtml", "Layout"))
.Returns(new RazorPageResult("Layout", Enumerable.Empty<string>()));
viewEngine
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "Layout", /*isMainPage*/ false))
.Setup(p => p.FindPage(It.IsAny<ActionContext>(), "Layout"))
.Returns(new RazorPageResult("/Layout.cshtml", layout));
var view = new RazorView(