From c1dd95be2a9fc94a8f27d273150fa2ca552db9e0 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Wed, 24 May 2017 16:41:25 -0700 Subject: [PATCH] Add a test for #6294 This case was fixed by 2992f8e - this commit just adds a test to verify the fix. --- .../RazorPagesTest.cs | 13 +++++++++++++ .../RazorPagesWebSite/Pages/Section/Index.cshtml | 10 ++++++++++ .../RazorPagesWebSite/Pages/Section/_Layout.cshtml | 1 + 3 files changed, 24 insertions(+) create mode 100644 test/WebSites/RazorPagesWebSite/Pages/Section/Index.cshtml create mode 100644 test/WebSites/RazorPagesWebSite/Pages/Section/_Layout.cshtml diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RazorPagesTest.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RazorPagesTest.cs index 8a6610eb7a..ac3bdc29b1 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RazorPagesTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RazorPagesTest.cs @@ -1011,6 +1011,19 @@ Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary`1[AspNetCore._InjectedP Assert.StartsWith(expected, response.Trim()); } + [Fact] + public async Task Page_WithSection_CanAccessModel() + { + // Arrange + var expected = "Value is 17"; + + // Act + var response = await Client.GetStringAsync("/Pages/Section"); + + // Assert + Assert.StartsWith(expected, response.Trim()); + } + private async Task AddAntiforgeryHeaders(HttpRequestMessage request) { var getResponse = await Client.GetAsync(request.RequestUri); diff --git a/test/WebSites/RazorPagesWebSite/Pages/Section/Index.cshtml b/test/WebSites/RazorPagesWebSite/Pages/Section/Index.cshtml new file mode 100644 index 0000000000..510e36fc40 --- /dev/null +++ b/test/WebSites/RazorPagesWebSite/Pages/Section/Index.cshtml @@ -0,0 +1,10 @@ +@page +@{ + Layout = "_Layout"; +} +@functions { + public int MyValue { get; set; } = 17; +} +@section mysection { + Value is @Model.MyValue +} \ No newline at end of file diff --git a/test/WebSites/RazorPagesWebSite/Pages/Section/_Layout.cshtml b/test/WebSites/RazorPagesWebSite/Pages/Section/_Layout.cshtml new file mode 100644 index 0000000000..bfdb853014 --- /dev/null +++ b/test/WebSites/RazorPagesWebSite/Pages/Section/_Layout.cshtml @@ -0,0 +1 @@ +@RenderSection("mysection") \ No newline at end of file