diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs
index bf2224bab0..ec65ba31d2 100644
--- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs
@@ -30,6 +30,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example s include string.Empty which identifies the current model and
/// "prop" which identifies the current model's "prop" property.
///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString Display([NotNull] this IHtmlHelper html, string expression)
{
@@ -61,6 +65,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example s include string.Empty which identifies the current model and
/// "prop" which identifies the current model's "prop" property.
///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString Display(
[NotNull] this IHtmlHelper html,
@@ -92,6 +100,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example s include string.Empty which identifies the current model and
/// "prop" which identifies the current model's "prop" property.
///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString Display(
[NotNull] this IHtmlHelper html,
@@ -127,6 +139,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example s include string.Empty which identifies the current model and
/// "prop" which identifies the current model's "prop" property.
///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString Display(
[NotNull] this IHtmlHelper html,
@@ -162,6 +178,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example s include string.Empty which identifies the current model and
/// "prop" which identifies the current model's "prop" property.
///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString Display(
[NotNull] this IHtmlHelper html,
@@ -182,8 +202,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The type of the result.
/// A new containing the created HTML.
///
+ ///
/// For example the default display template includes markup for each property in the
/// result.
+ ///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString DisplayFor([NotNull] this IHtmlHelper html,
[NotNull] Expression> expression)
@@ -208,8 +234,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The type of the result.
/// A new containing the created HTML.
///
+ ///
/// For example the default display template includes markup for each property in the
/// result.
+ ///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString DisplayFor([NotNull] this IHtmlHelper html,
[NotNull] Expression> expression,
@@ -231,8 +263,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The type of the result.
/// A new containing the created HTML.
///
+ ///
/// For example the default display template includes markup for each property in the
/// result.
+ ///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString DisplayFor([NotNull] this IHtmlHelper html,
[NotNull] Expression> expression,
@@ -258,8 +296,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The type of the result.
/// A new containing the created HTML.
///
+ ///
/// For example the default display template includes markup for each property in the
/// result.
+ ///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString DisplayFor([NotNull] this IHtmlHelper html,
[NotNull] Expression> expression,
@@ -286,8 +330,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The type of the result.
/// A new containing the created HTML.
///
+ ///
/// For example the default display template includes markup for each property in the
/// result.
+ ///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString DisplayFor([NotNull] this IHtmlHelper html,
[NotNull] Expression> expression,
@@ -305,8 +355,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The instance this method extends.
/// A new containing the created HTML.
///
+ ///
/// For example the default display template includes markup for each property in the
/// current model.
+ ///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html)
{
@@ -325,8 +381,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
///
/// A new containing the created HTML.
///
+ ///
/// For example the default display template includes markup for each property in the
/// current model.
+ ///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, object additionalViewData)
{
@@ -342,8 +404,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The name of the template used to create the HTML markup.
/// A new containing the created HTML.
///
+ ///
/// For example the default display template includes markup for each property in the
/// current model.
+ ///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, string templateName)
{
@@ -365,8 +433,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
///
/// A new containing the created HTML.
///
+ ///
/// For example the default display template includes markup for each property in the
/// current model.
+ ///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString DisplayForModel(
[NotNull] this IHtmlHelper html,
@@ -390,8 +464,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
///
/// A new containing the created HTML.
///
+ ///
/// For example the default display template includes markup for each property in the
/// current model.
+ ///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString DisplayForModel(
[NotNull] this IHtmlHelper html,
@@ -420,8 +500,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
///
/// A new containing the created HTML.
///
+ ///
/// For example the default display template includes markup for each property in the
/// current model.
+ ///
+ ///
+ /// Custom templates are found under a DisplayTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString DisplayForModel(
[NotNull] this IHtmlHelper html,
diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs
index 3dd75b6837..f6f54fbc66 100644
--- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs
@@ -30,6 +30,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example s include string.Empty which identifies the current model and
/// "prop" which identifies the current model's "prop" property.
///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression)
{
@@ -61,6 +65,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example s include string.Empty which identifies the current model and
/// "prop" which identifies the current model's "prop" property.
///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, object additionalViewData)
{
@@ -89,6 +97,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example s include string.Empty which identifies the current model and
/// "prop" which identifies the current model's "prop" property.
///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName)
{
@@ -121,6 +133,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example s include string.Empty which identifies the current model and
/// "prop" which identifies the current model's "prop" property.
///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName,
object additionalViewData)
@@ -153,6 +169,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// Example s include string.Empty which identifies the current model and
/// "prop" which identifies the current model's "prop" property.
///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName,
string htmlFieldName)
@@ -170,8 +190,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The type of the result.
/// A new containing the <input> element(s).
///
+ ///
/// For example the default editor template includes <label> and <input>
/// elements for each property in the result.
+ ///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString EditorFor([NotNull] this IHtmlHelper html,
[NotNull] Expression> expression)
@@ -195,8 +221,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The type of the result.
/// A new containing the <input> element(s).
///
+ ///
/// For example the default editor template includes <label> and <input>
/// elements for each property in the result.
+ ///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString EditorFor([NotNull] this IHtmlHelper html,
[NotNull] Expression> expression, object additionalViewData)
@@ -217,8 +249,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The type of the result.
/// A new containing the <input> element(s).
///
+ ///
/// For example the default editor template includes <label> and <input>
/// elements for each property in the result.
+ ///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString EditorFor([NotNull] this IHtmlHelper html,
[NotNull] Expression> expression, string templateName)
@@ -243,8 +281,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The type of the result.
/// A new containing the <input> element(s).
///
+ ///
/// For example the default editor template includes <label> and <input>
/// elements for each property in the result.
+ ///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString EditorFor([NotNull] this IHtmlHelper html,
[NotNull] Expression> expression, string templateName, object additionalViewData)
@@ -269,8 +313,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The type of the result.
/// A new containing the <input> element(s).
///
+ ///
/// For example the default editor template includes <label> and <input>
/// elements for each property in the result.
+ ///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString EditorFor([NotNull] this IHtmlHelper html,
[NotNull] Expression> expression, string templateName, string htmlFieldName)
@@ -285,8 +335,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The instance this method extends.
/// A new containing the <input> element(s).
///
+ ///
/// For example the default editor template includes <label> and <input>
/// elements for each property in the result.
+ ///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html)
{
@@ -305,8 +361,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
///
/// A new containing the <input> element(s).
///
+ ///
/// For example the default editor template includes <label> and <input>
/// elements for each property in the current model.
+ ///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, object additionalViewData)
{
@@ -322,8 +384,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// The name of the template used to create the HTML markup.
/// A new containing the <input> element(s).
///
+ ///
/// For example the default editor template includes <label> and <input>
/// elements for each property in the current model.
+ ///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName)
{
@@ -345,8 +413,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
///
/// A new containing the <input> element(s).
///
+ ///
/// For example the default editor template includes <label> and <input>
/// elements for each property in the current model.
+ ///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName,
object additionalViewData)
@@ -368,8 +442,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
///
/// A new containing the <input> element(s).
///
+ ///
/// For example the default editor template includes <label> and <input>
/// elements for each property in the current model.
+ ///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName,
string htmlFieldName)
@@ -396,8 +476,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
///
/// A new containing the <input> element(s).
///
+ ///
/// For example the default editor template includes <label> and <input>
/// elements for each property in the current model.
+ ///
+ ///
+ /// Custom templates are found under a EditorTemplates folder. The folder name is case-sensitive on
+ /// case-sensitive file systems.
+ ///
///
public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName,
string htmlFieldName, object additionalViewData)
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs
index 1fd6a3438f..f582bb8723 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorParser.cs
@@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Mvc.Razor
{
///
/// A subtype of that uses to support inheritance of tag
- /// helpers from _viewstart files.
+ /// helpers from _ViewStart files.
///
public class MvcRazorParser : RazorParser
{
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/ViewStartUtility.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/ViewStartUtility.cs
index 0a8b9e3c2d..45b2bc48e0 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/ViewStartUtility.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/ViewStartUtility.cs
@@ -8,9 +8,12 @@ using System.Linq;
namespace Microsoft.AspNet.Mvc.Razor
{
+ ///
+ /// Contains the methods to locate _ViewStart.cshtml
+ ///
public static class ViewStartUtility
{
- private const string ViewStartFileName = "_viewstart.cshtml";
+ private const string ViewStartFileName = "_ViewStart.cshtml";
///
/// Determines if the given path represents a view start file.
diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs
index 3779f18633..a3f86ef132 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs
@@ -13,6 +13,10 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// Default implementation of .
///
+ ///
+ /// For ViewResults returned from controllers, views should be located in
+ /// by default. For the controllers in an area, views should exist in .
+ ///
public class RazorViewEngine : IRazorViewEngine
{
private const string ViewExtension = ".cshtml";
@@ -55,6 +59,16 @@ namespace Microsoft.AspNet.Mvc.Razor
///
/// Gets the locations where this instance of will search for views.
///
+ ///
+ /// The locations of the views returned from controllers that do not belong to an area.
+ /// Locations are composite format strings (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx),
+ /// which contains following indexes:
+ /// {0} - Action Name
+ /// {1} - Controller Name
+ /// The values for these locations are case-sensitive on case-senstive file systems.
+ /// For example, the view for the Test action of HomeController should be located at
+ /// /Views/Home/Test.cshtml. Locations such as /views/home/test.cshtml would not be discovered
+ ///
public virtual IEnumerable ViewLocationFormats
{
get { return _viewLocationFormats; }
@@ -64,6 +78,17 @@ namespace Microsoft.AspNet.Mvc.Razor
/// Gets the locations where this instance of will search for views within an
/// area.
///
+ ///
+ /// The locations of the views returned from controllers that belong to an area.
+ /// Locations are composite format strings (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx),
+ /// which contains following indexes:
+ /// {0} - Action Name
+ /// {1} - Controller Name
+ /// {2} - Area name
+ /// The values for these locations are case-sensitive on case-senstive file systems.
+ /// For example, the view for the Test action of HomeController should be located at
+ /// /Views/Home/Test.cshtml. Locations such as /views/home/test.cshtml would not be discovered
+ ///
public virtual IEnumerable AreaViewLocationFormats
{
get { return _areaViewLocationFormats; }
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultDisplayTemplatesTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultDisplayTemplatesTest.cs
index 765dd05fae..0078efd250 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultDisplayTemplatesTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultDisplayTemplatesTest.cs
@@ -291,5 +291,23 @@ namespace Microsoft.AspNet.Mvc.Core
var ex = Assert.Throws(() => helper.DisplayFor(m => m.Property1));
Assert.Equal(expectedMessage, ex.Message);
}
+
+ [Fact]
+ public void Display_CallsFindPartialView_WithExpectedPath()
+ {
+ // Arrange
+ var viewEngine = new Mock(MockBehavior.Strict);
+
+ viewEngine
+ .Setup(v => v.FindPartialView(It.IsAny(),
+ It.Is(view => view.Equals("DisplayTemplates/String"))))
+ .Returns(ViewEngineResult.Found(string.Empty, new Mock().Object))
+ .Verifiable();
+ var html = DefaultTemplatesUtilities.GetHtmlHelper(new object(), viewEngine: viewEngine.Object);
+
+ // Act & Assert
+ html.Display(expression: string.Empty, templateName: null, htmlFieldName: null, additionalViewData: null);
+ viewEngine.Verify();
+ }
}
}
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultEditorTemplatesTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultEditorTemplatesTests.cs
index b0e414dd61..46ad8c3e61 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultEditorTemplatesTests.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/DefaultEditorTemplatesTests.cs
@@ -684,6 +684,24 @@ Environment.NewLine;
Assert.Equal(expectedMessage, ex.Message);
}
+ [Fact]
+ public void EditorForModel_CallsFindPartialView_WithExpectedPath()
+ {
+ // Arrange
+ var viewEngine = new Mock(MockBehavior.Strict);
+ viewEngine
+ .Setup(v => v.FindPartialView(It.IsAny(),
+ It.Is(view => String.Equals(view,
+ "EditorTemplates/String"))))
+ .Returns(ViewEngineResult.Found(string.Empty, new Mock().Object))
+ .Verifiable();
+ var html = DefaultTemplatesUtilities.GetHtmlHelper(new object(), viewEngine: viewEngine.Object);
+
+ // Act & Assert
+ html.Editor(expression: string.Empty, templateName: null, htmlFieldName: null, additionalViewData: null);
+ viewEngine.Verify();
+ }
+
private class StubbyHtmlHelper : IHtmlHelper, ICanHasViewContext
{
private readonly IHtmlHelper _innerHelper;
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/ViewEngine/CompositeViewEngineTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/ViewEngine/CompositeViewEngineTest.cs
index a36eaad895..a0e34c1774 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/ViewEngine/CompositeViewEngineTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/ViewEngine/CompositeViewEngineTest.cs
@@ -159,7 +159,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
var provider = new Mock();
var engine = new Mock();
engine.Setup(e => e.FindPartialView(It.IsAny(), It.IsAny()))
- .Returns(ViewEngineResult.NotFound(viewName, new[] { "shared/partial-view" }));
+ .Returns(ViewEngineResult.NotFound(viewName, new[] { "Shared/partial-view" }));
provider.SetupGet(p => p.ViewEngines)
.Returns(new[] { engine.Object });
var compositeViewEngine = new CompositeViewEngine(provider.Object);
@@ -169,7 +169,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
// Assert
Assert.False(result.Success);
- Assert.Equal(new[] { "shared/partial-view" }, result.SearchedLocations);
+ Assert.Equal(new[] { "Shared/partial-view" }, result.SearchedLocations);
}
[Fact]
diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ViewComponents/ViewViewComponentResultTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ViewComponents/ViewViewComponentResultTest.cs
index af40cc7010..07f076ce18 100644
--- a/test/Microsoft.AspNet.Mvc.Core.Test/ViewComponents/ViewViewComponentResultTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Core.Test/ViewComponents/ViewViewComponentResultTest.cs
@@ -276,6 +276,28 @@ namespace Microsoft.AspNet.Mvc
Assert.Equal(expected, ex.Message);
}
+ [Fact]
+ public void Execute_CallsFindPartialView_WithExpectedPath()
+ {
+ // Arrange
+ var viewEngine = new Mock(MockBehavior.Strict);
+ viewEngine
+ .Setup(v => v.FindPartialView(It.IsAny(),
+ It.Is(view => view.Contains("Components"))))
+ .Returns(ViewEngineResult.Found(string.Empty, new Mock().Object))
+ .Verifiable();
+
+ var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
+ var componentContext = GetViewComponentContext(new Mock().Object, viewData);
+ var componentResult = new ViewViewComponentResult();
+ componentResult.ViewEngine = viewEngine.Object;
+ componentResult.ViewData = viewData;
+
+ // Act & Assert
+ componentResult.Execute(componentContext);
+ viewEngine.Verify();
+ }
+
private static ViewComponentContext GetViewComponentContext(IView view, ViewDataDictionary viewData)
{
var actionContext = new ActionContext(new RouteContext(new DefaultHttpContext()), new ActionDescriptor());
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/Directives/ChunkInheritanceUtilityTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/Directives/ChunkInheritanceUtilityTest.cs
index 8043eda272..b39ba3a8ac 100644
--- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/Directives/ChunkInheritanceUtilityTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/Directives/ChunkInheritanceUtilityTest.cs
@@ -13,10 +13,10 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
{
// Arrange
var fileSystem = new TestFileSystem();
- fileSystem.AddFile(@"views\accounts\_viewstart.cshtml", "@using AccountModels");
- fileSystem.AddFile(@"views\Shared\_viewstart.cshtml", "@inject SharedHelper Shared");
- fileSystem.AddFile(@"views\home\_viewstart.cshtml", "@using MyNamespace");
- fileSystem.AddFile(@"views\_viewstart.cshtml",
+ fileSystem.AddFile(@"Views\accounts\_ViewStart.cshtml", "@using AccountModels");
+ fileSystem.AddFile(@"Views\Shared\_ViewStart.cshtml", "@inject SharedHelper Shared");
+ fileSystem.AddFile(@"Views\home\_ViewStart.cshtml", "@using MyNamespace");
+ fileSystem.AddFile(@"Views\_ViewStart.cshtml",
@"@inject MyHelper Helper
@inherits MyBaseType
@@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
var utility = new ChunkInheritanceUtility(host, fileSystem, new Chunk[0]);
// Act
- var chunks = utility.GetInheritedChunks(@"views\home\Index.cshtml");
+ var chunks = utility.GetInheritedChunks(@"Views\home\Index.cshtml");
// Assert
Assert.Equal(8, chunks.Count);
@@ -57,14 +57,14 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
{
// Arrange
var fileSystem = new TestFileSystem();
- fileSystem.AddFile(@"_viewstart.cs", string.Empty);
- fileSystem.AddFile(@"views\_Layout.cshtml", string.Empty);
- fileSystem.AddFile(@"views\home\_not-viewstart.cshtml", string.Empty);
+ fileSystem.AddFile(@"_ViewStart.cs", string.Empty);
+ fileSystem.AddFile(@"Views\_Layout.cshtml", string.Empty);
+ fileSystem.AddFile(@"Views\home\_not-viewstart.cshtml", string.Empty);
var host = new MvcRazorHost(fileSystem);
var utility = new ChunkInheritanceUtility(host, fileSystem, new Chunk[0]);
// Act
- var chunks = utility.GetInheritedChunks(@"views\home\Index.cshtml");
+ var chunks = utility.GetInheritedChunks(@"Views\home\Index.cshtml");
// Assert
Assert.Empty(chunks);
@@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
{
// Arrange
var fileSystem = new TestFileSystem();
- fileSystem.AddFile(@"views\_viewstart.cshtml",
+ fileSystem.AddFile(@"Views\_ViewStart.cshtml",
"@inject DifferentHelper Html");
var host = new MvcRazorHost(fileSystem);
var defaultChunks = new Chunk[]
@@ -86,7 +86,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
var utility = new ChunkInheritanceUtility(host, fileSystem, defaultChunks);
// Act
- var chunks = utility.GetInheritedChunks(@"views\Home\Index.cshtml");
+ var chunks = utility.GetInheritedChunks(@"Views\Home\Index.cshtml");
// Assert
Assert.Equal(4, chunks.Count);
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/Areas/MyArea/Sub/Views/Admin/_ViewStart.cshtml b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/Areas/MyArea/Sub/Views/Admin/_ViewStart.cshtml
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/Areas/MyArea/Sub/Views/Admin/_viewstart.cshtml b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/Areas/MyArea/Sub/Views/Admin/_viewstart.cshtml
deleted file mode 100644
index 5f282702bb..0000000000
--- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/Areas/MyArea/Sub/Views/Admin/_viewstart.cshtml
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/Views/Home/_ViewStart.cshtml b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/Views/Home/_ViewStart.cshtml
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/Views/Home/_viewstart.cshtml b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/Views/Home/_viewstart.cshtml
deleted file mode 100644
index 5f282702bb..0000000000
--- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/Views/Home/_viewstart.cshtml
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/_viewstart.cshtml b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/_viewstart.cshtml
deleted file mode 100644
index 5f282702bb..0000000000
--- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/TestFiles/ViewStartUtilityFiles/_viewstart.cshtml
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewStartUtilityTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewStartUtilityTest.cs
index c645dcb55a..be00bf8065 100644
--- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewStartUtilityTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewStartUtilityTest.cs
@@ -24,17 +24,17 @@ namespace Microsoft.AspNet.Mvc.Razor
}
[Theory]
- [InlineData("/views/Home/MyView.cshtml")]
- [InlineData("~/views/Home/MyView.cshtml")]
- [InlineData("views/Home/MyView.cshtml")]
+ [InlineData("/Views/Home/MyView.cshtml")]
+ [InlineData("~/Views/Home/MyView.cshtml")]
+ [InlineData("Views/Home/MyView.cshtml")]
public void GetViewStartLocations_ReturnsPotentialViewStartLocations_PathStartswithSlash(string inputPath)
{
// Arrange
var expected = new[]
{
- @"views\Home\_viewstart.cshtml",
- @"views\_viewstart.cshtml",
- @"_viewstart.cshtml"
+ @"Views\Home\_ViewStart.cshtml",
+ @"Views\_ViewStart.cshtml",
+ @"_ViewStart.cshtml"
};
// Act
@@ -45,16 +45,16 @@ namespace Microsoft.AspNet.Mvc.Razor
}
[Theory]
- [InlineData("/views/Home/_ViewStart.cshtml")]
- [InlineData("~/views/Home/_viewstart.cshtml")]
- [InlineData("views/Home/_Viewstart.cshtml")]
+ [InlineData("/Views/Home/_ViewStart.cshtml")]
+ [InlineData("~/Views/Home/_Viewstart.cshtml")]
+ [InlineData("Views/Home/_Viewstart.cshtml")]
public void GetViewStartLocations_SkipsCurrentPath_IfCurrentIsViewStart(string inputPath)
{
// Arrange
var expected = new[]
{
- @"views\_viewstart.cshtml",
- @"_viewstart.cshtml"
+ @"Views\_ViewStart.cshtml",
+ @"_ViewStart.cshtml"
};
var fileSystem = new PhysicalFileSystem(GetTestFileSystemBase());
@@ -73,12 +73,12 @@ namespace Microsoft.AspNet.Mvc.Razor
// Arrange
var expected = new[]
{
- @"Areas\MyArea\Sub\Views\Admin\_viewstart.cshtml",
- @"Areas\MyArea\Sub\Views\_viewstart.cshtml",
- @"Areas\MyArea\Sub\_viewstart.cshtml",
- @"Areas\MyArea\_viewstart.cshtml",
- @"Areas\_viewstart.cshtml",
- @"_viewstart.cshtml",
+ @"Areas\MyArea\Sub\Views\Admin\_ViewStart.cshtml",
+ @"Areas\MyArea\Sub\Views\_ViewStart.cshtml",
+ @"Areas\MyArea\Sub\_ViewStart.cshtml",
+ @"Areas\MyArea\_ViewStart.cshtml",
+ @"Areas\_ViewStart.cshtml",
+ @"_ViewStart.cshtml",
};
var viewPath = Path.Combine("Areas", "MyArea", "Sub", "Views", "Admin", fileName);
@@ -97,11 +97,11 @@ namespace Microsoft.AspNet.Mvc.Razor
// Arrange
var expected = new[]
{
- @"Areas\MyArea\Sub\Views\_viewstart.cshtml",
- @"Areas\MyArea\Sub\_viewstart.cshtml",
- @"Areas\MyArea\_viewstart.cshtml",
- @"Areas\_viewstart.cshtml",
- @"_viewstart.cshtml",
+ @"Areas\MyArea\Sub\Views\_ViewStart.cshtml",
+ @"Areas\MyArea\Sub\_ViewStart.cshtml",
+ @"Areas\MyArea\_ViewStart.cshtml",
+ @"Areas\_ViewStart.cshtml",
+ @"_ViewStart.cshtml",
};
var viewPath = Path.Combine("Areas", "MyArea", "Sub", "Views", "Admin", fileName);
@@ -117,7 +117,7 @@ namespace Microsoft.AspNet.Mvc.Razor
{
// Arrange
var appBase = GetTestFileSystemBase();
- var viewPath = "_viewstart.cshtml";
+ var viewPath = "_ViewStart.cshtml";
// Act
var result = ViewStartUtility.GetViewStartLocations(viewPath);
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorCompilationServiceTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorCompilationServiceTest.cs
index 8338be5dd8..4ed83270c0 100644
--- a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorCompilationServiceTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorCompilationServiceTest.cs
@@ -14,13 +14,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
public class RazorCompilationServiceTest
{
[Theory]
- [InlineData(@"src\work\myapp", @"src\work\myapp\views\index\home.cshtml")]
- [InlineData(@"src\work\myapp\", @"src\work\myapp\views\index\home.cshtml")]
+ [InlineData(@"src\work\myapp", @"src\work\myapp\Views\index\home.cshtml")]
+ [InlineData(@"src\work\myapp\", @"src\work\myapp\Views\index\home.cshtml")]
public void CompileCalculatesRootRelativePath(string appPath, string viewPath)
{
// Arrange
var host = new Mock();
- host.Setup(h => h.GenerateCode(@"views\index\home.cshtml", It.IsAny()))
+ host.Setup(h => h.GenerateCode(@"Views\index\home.cshtml", It.IsAny()))
.Returns(GetGeneratorResult())
.Verifiable();
@@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
var relativeFileInfo = new RelativeFileInfo()
{
FileInfo = fileInfo.Object,
- RelativePath = @"views\index\home.cshtml",
+ RelativePath = @"Views\index\home.cshtml",
};
// Act
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewEngineTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewEngineTest.cs
index c07bbf87d1..027f31f713 100644
--- a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewEngineTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewEngineTest.cs
@@ -594,6 +594,38 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
Assert.Equal(expected, result.SearchedLocations);
}
+ [Fact]
+ public void AreaViewLocationFormats_ContainsExpectedLocations()
+ {
+ // Arrange
+ var viewEngine = CreateViewEngine();
+ var areaViewLocations = new string[]
+ {
+ "/Areas/{2}/Views/{1}/{0}.cshtml",
+ "/Areas/{2}/Views/Shared/{0}.cshtml",
+ "/Views/Shared/{0}.cshtml"
+ };
+
+ // Act & Assert
+ Assert.Equal(areaViewLocations, viewEngine.AreaViewLocationFormats);
+ }
+
+ [Fact]
+ public void ViewLocationFormats_ContainsExpectedLocations()
+ {
+ // Arrange
+ var viewEngine = CreateViewEngine();
+
+ var viewLocations = new string[]
+ {
+ "/Views/{1}/{0}.cshtml",
+ "/Views/Shared/{0}.cshtml"
+ };
+
+ // Act & Assert
+ Assert.Equal(viewLocations, viewEngine.ViewLocationFormats);
+ }
+
private RazorViewEngine CreateViewEngine(IRazorPageFactory pageFactory = null,
IRazorViewFactory viewFactory = null,
IEnumerable expanders = null,
diff --git a/test/WebSites/RazorWebSite/Views/NestedViewStarts/_viewstart.cshtml b/test/WebSites/RazorWebSite/Views/NestedViewStarts/_ViewStart.cshtml
similarity index 91%
rename from test/WebSites/RazorWebSite/Views/NestedViewStarts/_viewstart.cshtml
rename to test/WebSites/RazorWebSite/Views/NestedViewStarts/_ViewStart.cshtml
index f9a46cb429..4719f448aa 100644
--- a/test/WebSites/RazorWebSite/Views/NestedViewStarts/_viewstart.cshtml
+++ b/test/WebSites/RazorWebSite/Views/NestedViewStarts/_ViewStart.cshtml
@@ -1,3 +1,3 @@
-@{
+@{
Layout = "~/Views/NestedViewStarts/NestedViewStarts/Layout.cshtml";
}
\ No newline at end of file
diff --git a/test/WebSites/ViewComponentWebSite/Views/_ViewStart.cshtml b/test/WebSites/ViewComponentWebSite/Views/_ViewStart.cshtml
new file mode 100644
index 0000000000..d6ce3cfe9b
--- /dev/null
+++ b/test/WebSites/ViewComponentWebSite/Views/_ViewStart.cshtml
@@ -0,0 +1 @@
+@using ViewComponentWebSite
\ No newline at end of file
diff --git a/test/WebSites/ViewComponentWebSite/Views/_viewstart.cshtml b/test/WebSites/ViewComponentWebSite/Views/_viewstart.cshtml
deleted file mode 100644
index 8789eff591..0000000000
--- a/test/WebSites/ViewComponentWebSite/Views/_viewstart.cshtml
+++ /dev/null
@@ -1 +0,0 @@
-@using ViewComponentWebSite
\ No newline at end of file