Fixing tests
This commit is contained in:
parent
52f4a83139
commit
a9d5876cd9
|
|
@ -206,7 +206,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
writer.Write(" ");
|
||||
writer.Write(key);
|
||||
writer.Write("=\"");
|
||||
encoder.Encode(writer, attribute.Value);
|
||||
if (!string.IsNullOrEmpty(attribute.Value))
|
||||
{
|
||||
encoder.Encode(writer, attribute.Value);
|
||||
}
|
||||
writer.Write("\"");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,10 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
|
|||
throw new ArgumentNullException(nameof(encoder));
|
||||
}
|
||||
|
||||
encoder.Encode(writer, _input);
|
||||
if (!string.IsNullOrEmpty(_input))
|
||||
{
|
||||
encoder.Encode(writer, _input);
|
||||
}
|
||||
}
|
||||
|
||||
private string DebuggerToString()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<!doctype html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
|
@ -62,10 +62,10 @@
|
|||
</script>
|
||||
|
||||
<!-- Globbed script tag with existing file -->
|
||||
<script src="HtmlEncode[[/styles/site.js]]"></script>
|
||||
HtmlEncode[[]]<script src="HtmlEncode[[/styles/site.js]]"></script>
|
||||
|
||||
<!-- Globbed script tag with existing file and exclude -->
|
||||
<script src="HtmlEncode[[/styles/site.js]]"></script><script src="HtmlEncode[[/styles/sub/site2.js]]"></script>
|
||||
HtmlEncode[[]]<script src="HtmlEncode[[/styles/site.js]]"></script><script src="HtmlEncode[[/styles/sub/site2.js]]"></script>
|
||||
|
||||
<script>
|
||||
// Globbed script tag missing include
|
||||
|
|
@ -76,16 +76,16 @@
|
|||
</script>
|
||||
|
||||
<!-- Globbed script tag with comma separated include pattern -->
|
||||
<script src="HtmlEncode[[/styles/site.js]]"></script><script src="HtmlEncode[[/styles/sub/site2.js]]"></script><script src="HtmlEncode[[/styles/sub/site3.js]]"></script>
|
||||
HtmlEncode[[]]<script src="HtmlEncode[[/styles/site.js]]"></script><script src="HtmlEncode[[/styles/sub/site2.js]]"></script><script src="HtmlEncode[[/styles/sub/site3.js]]"></script>
|
||||
|
||||
<!-- Globbed script tag with missing file -->
|
||||
|
||||
HtmlEncode[[]]
|
||||
|
||||
<!-- Globbed script tag with file outside of webroot -->
|
||||
|
||||
HtmlEncode[[]]
|
||||
|
||||
<!-- Globbed script tag with file outside of webroot -->
|
||||
|
||||
HtmlEncode[[]]
|
||||
|
||||
<script src="HtmlEncode[[/styles/site.js]]">
|
||||
// Globbed script tag with existing file and static src
|
||||
|
|
@ -110,9 +110,9 @@
|
|||
</script>
|
||||
|
||||
<!-- Globbed script tag with existing files and version -->
|
||||
<script src="HtmlEncode[[/styles/site.js?v=jx1PJjLX32-xgQQx2BxnckU9QH9DVKkm4-M5bSK869I]]"></script><script src="HtmlEncode[[/styles/sub/site2.js?v=pwJaxaQxnb-rPAdF2JlAp4xiPNq1XuJFd6TyOOfNF-0]]"></script><script src="HtmlEncode[[/styles/sub/site3.js?v=lmeAMiqm76lnGyqHhu6PIBHAC0Vt46mgVB_KaG_gGdA]]"></script>
|
||||
HtmlEncode[[]]<script src="HtmlEncode[[/styles/site.js?v=jx1PJjLX32-xgQQx2BxnckU9QH9DVKkm4-M5bSK869I]]"></script><script src="HtmlEncode[[/styles/sub/site2.js?v=pwJaxaQxnb-rPAdF2JlAp4xiPNq1XuJFd6TyOOfNF-0]]"></script><script src="HtmlEncode[[/styles/sub/site3.js?v=lmeAMiqm76lnGyqHhu6PIBHAC0Vt46mgVB_KaG_gGdA]]"></script>
|
||||
|
||||
<!-- Globbed script tag with existing file, exclude and version -->
|
||||
<script src="HtmlEncode[[/styles/site.js?v=jx1PJjLX32-xgQQx2BxnckU9QH9DVKkm4-M5bSK869I]]"></script><script src="HtmlEncode[[/styles/sub/site2.js?v=pwJaxaQxnb-rPAdF2JlAp4xiPNq1XuJFd6TyOOfNF-0]]"></script>
|
||||
HtmlEncode[[]]<script src="HtmlEncode[[/styles/site.js?v=jx1PJjLX32-xgQQx2BxnckU9QH9DVKkm4-M5bSK869I]]"></script><script src="HtmlEncode[[/styles/sub/site2.js?v=pwJaxaQxnb-rPAdF2JlAp4xiPNq1XuJFd6TyOOfNF-0]]"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http.Internal;
|
||||
using Microsoft.AspNet.Mvc.Abstractions;
|
||||
|
|
@ -16,7 +17,6 @@ using Microsoft.AspNet.Mvc.ViewEngines;
|
|||
using Microsoft.AspNet.Mvc.ViewFeatures;
|
||||
using Microsoft.AspNet.Razor.TagHelpers;
|
||||
using Microsoft.AspNet.Routing;
|
||||
using Microsoft.Extensions.WebEncoders.Testing;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -60,13 +60,14 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
|
|||
.Setup(mock => mock.Action(It.IsAny<UrlActionContext>())).Returns("home/index");
|
||||
|
||||
var htmlGenerator = new TestableHtmlGenerator(metadataProvider, urlHelper.Object);
|
||||
var viewContext = TestableHtmlGenerator.GetViewContext(model: null,
|
||||
htmlGenerator: htmlGenerator,
|
||||
metadataProvider: metadataProvider);
|
||||
var viewContext = TestableHtmlGenerator.GetViewContext(
|
||||
model: null,
|
||||
htmlGenerator: htmlGenerator,
|
||||
metadataProvider: metadataProvider);
|
||||
var expectedPostContent = "Something" +
|
||||
HtmlContentUtilities.HtmlContentToString(
|
||||
htmlGenerator.GenerateAntiforgery(viewContext),
|
||||
new HtmlTestEncoder());
|
||||
HtmlEncoder.Default);
|
||||
var formTagHelper = new FormTagHelper(htmlGenerator)
|
||||
{
|
||||
Action = "index",
|
||||
|
|
|
|||
|
|
@ -45,15 +45,15 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
|
|||
modelWithNull,
|
||||
modelWithText,
|
||||
};
|
||||
var noneSelected = "<option></option>" + Environment.NewLine +
|
||||
var noneSelected = "<option>HtmlEncode[[]]</option>" + Environment.NewLine +
|
||||
"<option>HtmlEncode[[outer text]]</option>" + Environment.NewLine +
|
||||
"<option>HtmlEncode[[inner text]]</option>" + Environment.NewLine +
|
||||
"<option>HtmlEncode[[other text]]</option>" + Environment.NewLine;
|
||||
var innerSelected = "<option></option>" + Environment.NewLine +
|
||||
var innerSelected = "<option>HtmlEncode[[]]</option>" + Environment.NewLine +
|
||||
"<option>HtmlEncode[[outer text]]</option>" + Environment.NewLine +
|
||||
"<option selected=\"HtmlEncode[[selected]]\">HtmlEncode[[inner text]]</option>" + Environment.NewLine +
|
||||
"<option>HtmlEncode[[other text]]</option>" + Environment.NewLine;
|
||||
var outerSelected = "<option></option>" + Environment.NewLine +
|
||||
var outerSelected = "<option>HtmlEncode[[]]</option>" + Environment.NewLine +
|
||||
"<option selected=\"HtmlEncode[[selected]]\">HtmlEncode[[outer text]]</option>" + Environment.NewLine +
|
||||
"<option>HtmlEncode[[inner text]]</option>" + Environment.NewLine +
|
||||
"<option>HtmlEncode[[other text]]</option>" + Environment.NewLine;
|
||||
|
|
|
|||
|
|
@ -48,32 +48,35 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
|
|||
{
|
||||
{ null, typeof(Model), null,
|
||||
new NameAndId("Text", "Text"),
|
||||
Environment.NewLine },
|
||||
Environment.NewLine + "HtmlEncode[[]]" },
|
||||
|
||||
{ modelWithNull, typeof(Model), modelWithNull.Text,
|
||||
new NameAndId("Text", "Text"),
|
||||
Environment.NewLine },
|
||||
Environment.NewLine + "HtmlEncode[[]]"},
|
||||
{ modelWithText, typeof(Model), modelWithText.Text,
|
||||
new NameAndId("Text", "Text"),
|
||||
Environment.NewLine + "HtmlEncode[[outer text]]" },
|
||||
|
||||
{ modelWithNull, typeof(NestedModel), modelWithNull.NestedModel.Text,
|
||||
new NameAndId("NestedModel.Text", "NestedModel_Text"),
|
||||
Environment.NewLine },
|
||||
Environment.NewLine + "HtmlEncode[[]]" },
|
||||
|
||||
{ modelWithText, typeof(NestedModel), modelWithText.NestedModel.Text,
|
||||
new NameAndId("NestedModel.Text", "NestedModel_Text"),
|
||||
Environment.NewLine + "HtmlEncode[[inner text]]" },
|
||||
|
||||
{ models, typeof(Model), models[0].Text,
|
||||
new NameAndId("[0].Text", "z0__Text"),
|
||||
Environment.NewLine },
|
||||
Environment.NewLine + "HtmlEncode[[]]" },
|
||||
|
||||
{ models, typeof(Model), models[1].Text,
|
||||
new NameAndId("[1].Text", "z1__Text"),
|
||||
Environment.NewLine + "HtmlEncode[[outer text]]" },
|
||||
|
||||
{ models, typeof(NestedModel), models[0].NestedModel.Text,
|
||||
new NameAndId("[0].NestedModel.Text", "z0__NestedModel_Text"),
|
||||
Environment.NewLine },
|
||||
Environment.NewLine + "HtmlEncode[[]]" },
|
||||
|
||||
{ models, typeof(NestedModel), models[1].NestedModel.Text,
|
||||
new NameAndId("[1].NestedModel.Text", "z1__NestedModel_Text"),
|
||||
Environment.NewLine + "HtmlEncode[[inner text]]" },
|
||||
|
|
|
|||
|
|
@ -63,9 +63,10 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
|
|||
output.Content.SetContent(expectedContent);
|
||||
output.PostContent.SetContent(expectedPostContent);
|
||||
|
||||
var viewContext = TestableHtmlGenerator.GetViewContext(model: null,
|
||||
htmlGenerator: htmlGenerator,
|
||||
metadataProvider: metadataProvider);
|
||||
var viewContext = TestableHtmlGenerator.GetViewContext(
|
||||
model: null,
|
||||
htmlGenerator: htmlGenerator,
|
||||
metadataProvider: metadataProvider);
|
||||
validationMessageTagHelper.ViewContext = viewContext;
|
||||
|
||||
// Act
|
||||
|
|
|
|||
Loading…
Reference in New Issue