Add functional test for Page.View() (#5896)
This commit is contained in:
parent
7bca31d079
commit
4a20c849cb
|
|
@ -113,6 +113,22 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
||||||
Assert.Equal("", content);
|
Assert.Equal("", content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task ViewReturnsPage()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/OnGetView");
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var response = await Client.SendAsync(request);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
|
||||||
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
|
Assert.Equal("The message: From OnGet", content.Trim());
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task TempData_SetTempDataInPage_CanReadValue()
|
public async Task TempData_SetTempDataInPage_CanReadValue()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
@page
|
||||||
|
|
||||||
|
@functions {
|
||||||
|
public IActionResult OnGet()
|
||||||
|
{
|
||||||
|
Message = "From OnGet";
|
||||||
|
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
public string Message { get; set; } = "Default";
|
||||||
|
}
|
||||||
|
The message: @Message
|
||||||
Loading…
Reference in New Issue