Added functional tests to cover rendering views without layout and
to return a result without content.
This commit is contained in:
parent
84396ad875
commit
16f19b5cc6
|
|
@ -68,6 +68,39 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||||
Assert.Equal(expectedContent, responseContent);
|
Assert.Equal(expectedContent, responseContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CanRender_SimpleViews()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var server = TestServer.Create(_provider, _app);
|
||||||
|
var client = server.Handler;
|
||||||
|
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync("BasicWebSite.Home.PlainView.html");
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await client.GetAsync("http://localhost/Home/PlainView");
|
||||||
|
Assert.Equal(200, result.StatusCode);
|
||||||
|
Assert.Equal(result.ContentType, "text/html; charset=utf-8");
|
||||||
|
var responseContent = await result.ReadBodyAsStringAsync();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(expectedContent, responseContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CanReturn_ResultsWithoutContent()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var server = TestServer.Create(_provider, _app);
|
||||||
|
var client = server.Handler;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = await client.GetAsync("http://localhost/Home/NoContentResult");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(204, result.StatusCode);
|
||||||
|
Assert.Equal("", await result.ReadBodyAsStringAsync());
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ActionDescriptors_CreatedOncePerRequest()
|
public async Task ActionDescriptors_CreatedOncePerRequest()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Plain View
|
||||||
|
|
@ -8,5 +8,15 @@ namespace BasicWebSite.Controllers
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IActionResult PlainView()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult NoContentResult()
|
||||||
|
{
|
||||||
|
return new HttpStatusCodeResult(204);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Plain View
|
||||||
Loading…
Reference in New Issue