Add RazorPage test without model
This commit is contained in:
parent
dbb682799e
commit
9e12230eef
|
|
@ -68,6 +68,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
{
|
||||
RunRuntimeTest("RazorPages", BuildDivDescriptors());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RazorEngine_RazorPagesWithoutModel_Runtime()
|
||||
{
|
||||
RunRuntimeTest("RazorPagesWithoutModel", BuildDivDescriptors());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DesignTime
|
||||
|
|
@ -124,6 +130,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
{
|
||||
RunDesignTimeTest("RazorPages", BuildDivDescriptors());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RazorEngine_RazorPagesWithoutModel_DesignTime()
|
||||
{
|
||||
RunDesignTimeTest("RazorPagesWithoutModel", BuildDivDescriptors());
|
||||
}
|
||||
#endregion
|
||||
|
||||
private static void RunRuntimeTest(string testName, IEnumerable<TagHelperDescriptor> descriptors = null)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
@page
|
||||
|
||||
@addTagHelper "*, TestAssembly"
|
||||
@using Microsoft.AspNetCore.Mvc.RazorPages
|
||||
|
||||
@functions {
|
||||
public IActionResult OnPost(Customer customer)
|
||||
{
|
||||
Name = customer.Name;
|
||||
return Redirect("~/customers/inlinepagemodels/");
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public class Customer
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
<h1>New Customer</h1>
|
||||
<form method="post" class="form-horizontal">
|
||||
<div class="text-danger"></div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">@Name</label>
|
||||
<div class="col-md-10">
|
||||
<input class="form-control" />
|
||||
<span class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<button type="submit" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using TModel = _TestFiles_Input_RazorPagesWithoutModel_cshtml;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
#line 2 ""
|
||||
using System.Linq;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 3 ""
|
||||
using System.Collections.Generic;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 4 ""
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 5 ""
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 6 ""
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 4 "/TestFiles/Input/RazorPagesWithoutModel.cshtml"
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
public class _TestFiles_Input_RazorPagesWithoutModel_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page
|
||||
{
|
||||
#pragma warning disable 219
|
||||
private void __RazorDirectiveTokenHelpers__() {
|
||||
((System.Action)(() => {
|
||||
System.Object __typeHelper = "*, TestAssembly";
|
||||
}
|
||||
))();
|
||||
}
|
||||
#pragma warning restore 219
|
||||
private static System.Object __o = null;
|
||||
private global::DivTagHelper __DivTagHelper = null;
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
__DivTagHelper = CreateTagHelper<global::DivTagHelper>();
|
||||
#line 25 "/TestFiles/Input/RazorPagesWithoutModel.cshtml"
|
||||
__o = Name;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
__DivTagHelper = CreateTagHelper<global::DivTagHelper>();
|
||||
__DivTagHelper = CreateTagHelper<global::DivTagHelper>();
|
||||
__DivTagHelper = CreateTagHelper<global::DivTagHelper>();
|
||||
__DivTagHelper = CreateTagHelper<global::DivTagHelper>();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
#line 6 "/TestFiles/Input/RazorPagesWithoutModel.cshtml"
|
||||
|
||||
public IActionResult OnPost(Customer customer)
|
||||
{
|
||||
Name = customer.Name;
|
||||
return Redirect("~/customers/inlinepagemodels/");
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public class Customer
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<_TestFiles_Input_RazorPagesWithoutModel_cshtml> Html { get; private set; }
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<_TestFiles_Input_RazorPagesWithoutModel_cshtml> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<_TestFiles_Input_RazorPagesWithoutModel_cshtml>)PageContext?.ViewData;
|
||||
public _TestFiles_Input_RazorPagesWithoutModel_cshtml Model => ViewData.Model;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
Source Location: (23:2,14 [17] /TestFiles/Input/RazorPagesWithoutModel.cshtml)
|
||||
|"*, TestAssembly"|
|
||||
Generated Location: (970:41,29 [17] )
|
||||
|"*, TestAssembly"|
|
||||
|
||||
Source Location: (571:24,47 [4] /TestFiles/Input/RazorPagesWithoutModel.cshtml)
|
||||
|Name|
|
||||
Generated Location: (1483:53,47 [4] )
|
||||
|Name|
|
||||
|
||||
Source Location: (100:5,12 [283] /TestFiles/Input/RazorPagesWithoutModel.cshtml)
|
||||
|
|
||||
public IActionResult OnPost(Customer customer)
|
||||
{
|
||||
Name = customer.Name;
|
||||
return Redirect("~/customers/inlinepagemodels/");
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public class Customer
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
|
||||
Generated Location: (1924:64,12 [283] )
|
||||
|
|
||||
public IActionResult OnPost(Customer customer)
|
||||
{
|
||||
Name = customer.Name;
|
||||
return Redirect("~/customers/inlinepagemodels/");
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public class Customer
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
|
||||
|
||||
|
|
@ -0,0 +1,218 @@
|
|||
#pragma checksum "/TestFiles/Input/RazorPagesWithoutModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c933419e57888c980327bbedf321c46e65488378"
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
#line 2 ""
|
||||
using System.Linq;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 3 ""
|
||||
using System.Collections.Generic;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 4 ""
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 5 ""
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 6 ""
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 4 "/TestFiles/Input/RazorPagesWithoutModel.cshtml"
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
public class _TestFiles_Input_RazorPagesWithoutModel_cshtml : global::Microsoft.AspNetCore.Mvc.RazorPages.Page
|
||||
{
|
||||
private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("text-danger"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
|
||||
private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
|
||||
private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("form-group"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
|
||||
private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute("class", new global::Microsoft.AspNetCore.Html.HtmlString("col-md-offset-2 col-md-10"), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
|
||||
#line hidden
|
||||
#pragma warning disable 0414
|
||||
private string __tagHelperStringValueBuffer = null;
|
||||
#pragma warning restore 0414
|
||||
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext __tagHelperExecutionContext = null;
|
||||
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner __tagHelperRunner = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner();
|
||||
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __backed__tagHelperScopeManager = null;
|
||||
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __tagHelperScopeManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (__backed__tagHelperScopeManager == null)
|
||||
{
|
||||
__backed__tagHelperScopeManager = new Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager(StartTagHelperWritingScope, EndTagHelperWritingScope);
|
||||
}
|
||||
return __backed__tagHelperScopeManager;
|
||||
}
|
||||
}
|
||||
private global::DivTagHelper __DivTagHelper = null;
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
BeginContext(7, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
EndContext();
|
||||
BeginContext(86, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
EndContext();
|
||||
BeginContext(386, 75, true);
|
||||
WriteLiteral("\r\n<h1>New Customer</h1>\r\n<form method=\"post\" class=\"form-horizontal\">\r\n ");
|
||||
EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => {
|
||||
}
|
||||
);
|
||||
__DivTagHelper = CreateTagHelper<global::DivTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__DivTagHelper);
|
||||
__tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_0);
|
||||
BeginContext(461, 31, false);
|
||||
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
|
||||
if (!__tagHelperExecutionContext.Output.IsContentModified)
|
||||
{
|
||||
await __tagHelperExecutionContext.SetOutputContentAsync();
|
||||
}
|
||||
Write(__tagHelperExecutionContext.Output);
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
EndContext();
|
||||
BeginContext(492, 6, true);
|
||||
WriteLiteral("\r\n ");
|
||||
EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => {
|
||||
BeginContext(522, 48, true);
|
||||
WriteLiteral("\r\n <label class=\"col-md-2 control-label\">");
|
||||
EndContext();
|
||||
BeginContext(571, 4, false);
|
||||
#line 25 "/TestFiles/Input/RazorPagesWithoutModel.cshtml"
|
||||
Write(Name);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
EndContext();
|
||||
BeginContext(575, 18, true);
|
||||
WriteLiteral("</label>\r\n ");
|
||||
EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => {
|
||||
BeginContext(616, 101, true);
|
||||
WriteLiteral("\r\n <input class=\"form-control\" />\r\n <span class=\"text-danger\"></span>\r\n ");
|
||||
EndContext();
|
||||
}
|
||||
);
|
||||
__DivTagHelper = CreateTagHelper<global::DivTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__DivTagHelper);
|
||||
__tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1);
|
||||
BeginContext(593, 130, false);
|
||||
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
|
||||
if (!__tagHelperExecutionContext.Output.IsContentModified)
|
||||
{
|
||||
await __tagHelperExecutionContext.SetOutputContentAsync();
|
||||
}
|
||||
Write(__tagHelperExecutionContext.Output);
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
EndContext();
|
||||
BeginContext(723, 6, true);
|
||||
WriteLiteral("\r\n ");
|
||||
EndContext();
|
||||
}
|
||||
);
|
||||
__DivTagHelper = CreateTagHelper<global::DivTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__DivTagHelper);
|
||||
__tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2);
|
||||
BeginContext(498, 237, false);
|
||||
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
|
||||
if (!__tagHelperExecutionContext.Output.IsContentModified)
|
||||
{
|
||||
await __tagHelperExecutionContext.SetOutputContentAsync();
|
||||
}
|
||||
Write(__tagHelperExecutionContext.Output);
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
EndContext();
|
||||
BeginContext(735, 6, true);
|
||||
WriteLiteral("\r\n ");
|
||||
EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => {
|
||||
BeginContext(765, 10, true);
|
||||
WriteLiteral("\r\n ");
|
||||
EndContext();
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("div", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "test", async() => {
|
||||
BeginContext(814, 83, true);
|
||||
WriteLiteral("\r\n <button type=\"submit\" class=\"btn btn-primary\">Save</button>\r\n ");
|
||||
EndContext();
|
||||
}
|
||||
);
|
||||
__DivTagHelper = CreateTagHelper<global::DivTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__DivTagHelper);
|
||||
__tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3);
|
||||
BeginContext(775, 128, false);
|
||||
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
|
||||
if (!__tagHelperExecutionContext.Output.IsContentModified)
|
||||
{
|
||||
await __tagHelperExecutionContext.SetOutputContentAsync();
|
||||
}
|
||||
Write(__tagHelperExecutionContext.Output);
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
EndContext();
|
||||
BeginContext(903, 6, true);
|
||||
WriteLiteral("\r\n ");
|
||||
EndContext();
|
||||
}
|
||||
);
|
||||
__DivTagHelper = CreateTagHelper<global::DivTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__DivTagHelper);
|
||||
__tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2);
|
||||
BeginContext(741, 174, false);
|
||||
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
|
||||
if (!__tagHelperExecutionContext.Output.IsContentModified)
|
||||
{
|
||||
await __tagHelperExecutionContext.SetOutputContentAsync();
|
||||
}
|
||||
Write(__tagHelperExecutionContext.Output);
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
EndContext();
|
||||
BeginContext(915, 11, true);
|
||||
WriteLiteral("\r\n</form>\r\n");
|
||||
EndContext();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
#line 6 "/TestFiles/Input/RazorPagesWithoutModel.cshtml"
|
||||
|
||||
public IActionResult OnPost(Customer customer)
|
||||
{
|
||||
Name = customer.Name;
|
||||
return Redirect("~/customers/inlinepagemodels/");
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public class Customer
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<_TestFiles_Input_RazorPagesWithoutModel_cshtml> Html { get; private set; }
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<_TestFiles_Input_RazorPagesWithoutModel_cshtml> ViewData => (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary<_TestFiles_Input_RazorPagesWithoutModel_cshtml>)PageContext?.ViewData;
|
||||
public _TestFiles_Input_RazorPagesWithoutModel_cshtml Model => ViewData.Model;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue