Add tests to ensure cshtml ending for full path view names.

#206
This commit is contained in:
N. Taylor Mullen 2014-04-30 16:33:24 -07:00
parent 3e398be1f8
commit c986c663e3
1 changed files with 46 additions and 0 deletions

View File

@ -36,6 +36,52 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
{"controller", "bar"},
};
[Theory]
[InlineData("~/foo/bar")]
[InlineData("/foo/bar")]
[InlineData("~/foo/bar.txt")]
[InlineData("/foo/bar.txt")]
public void FindViewFullPathRequiresCshtmlEnding(string viewName)
{
// Arrange
var viewEngine = CreateSearchLocationViewEngineTester();
// Act & Assert
Assert.Throws<InvalidOperationException>(() =>
viewEngine.FindView(_controllerTestContext, viewName));
// Append .cshtml so we can try and no longer throw.
viewName += ".cshtml";
// If this throws then our test case fails
var result = viewEngine.FindPartialView(_controllerTestContext, viewName);
Assert.False(result.Success);
}
[Theory]
[InlineData("~/foo/bar")]
[InlineData("/foo/bar")]
[InlineData("~/foo/bar.txt")]
[InlineData("/foo/bar.txt")]
public void FindPartialViewFullPathRequiresCshtmlEnding(string partialViewName)
{
// Arrange
var viewEngine = CreateSearchLocationViewEngineTester();
// Act & Assert
Assert.Throws<InvalidOperationException>(() =>
viewEngine.FindPartialView(_controllerTestContext, partialViewName));
// Append .cshtml so we can try and no longer throw.
partialViewName += ".cshtml";
// If this throws then our test case fails
var result = viewEngine.FindPartialView(_controllerTestContext, partialViewName);
Assert.False(result.Success);
}
[Fact]
public void FindPartialViewFailureSearchesCorrectLocationsWithAreas()
{