Skip to content

Commit

Permalink
Revert "Fixing tests"
Browse files Browse the repository at this point in the history
- wrong fix especially now that test encoders work as expected
- touch up `HtmlHelperTest` and `RazorViewTest` since test encoders are now consistent
- remove references to old `Microsoft.Extensions.WebEncoders.Testing` package

This reverts commit a9d5876.
- but leave `FormTagHelperTest` and `ValidationMessageTagHelperTest` cleanup alone

nit: use `string.Empty` in `HtmlHelperLinkGenerationTest`
dougbu committed Nov 2, 2015
1 parent c0b9dd1 commit ff91e79
Showing 21 changed files with 40 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -206,10 +206,7 @@ private void AppendAttributes(TextWriter writer, HtmlEncoder encoder)
writer.Write(" ");
writer.Write(key);
writer.Write("=\"");
if (!string.IsNullOrEmpty(attribute.Value))
{
encoder.Encode(writer, attribute.Value);
}
encoder.Encode(writer, attribute.Value);
writer.Write("\"");
}
}
Original file line number Diff line number Diff line change
@@ -39,10 +39,7 @@ public void WriteTo(TextWriter writer, HtmlEncoder encoder)
throw new ArgumentNullException(nameof(encoder));
}

if (!string.IsNullOrEmpty(_input))
{
encoder.Encode(writer, _input);
}
encoder.Encode(writer, _input);
}

private string DebuggerToString()
8 changes: 5 additions & 3 deletions test/Microsoft.AspNet.Mvc.ApiExplorer.Test/project.json
Original file line number Diff line number Diff line change
@@ -3,12 +3,14 @@
"warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNet.Mvc" : "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": {
"version": "6.0.0-*",
"type": "build"
},
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
5 changes: 2 additions & 3 deletions test/Microsoft.AspNet.Mvc.Core.Test/project.json
Original file line number Diff line number Diff line change
@@ -5,20 +5,19 @@
"dependencies": {
"Microsoft.AspNet.Http": "1.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": {
"version": "6.0.0-*",
"type": "build"
},
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources": {
"version": "6.0.0-*",
"type": "build"
},
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Microsoft.Extensions.DiagnosticAdapter": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
1 change: 0 additions & 1 deletion test/Microsoft.AspNet.Mvc.Cors.Test/project.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
1 change: 0 additions & 1 deletion test/Microsoft.AspNet.Mvc.Formatters.Xml.Test/project.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
"Microsoft.AspNet.Mvc.Formatters.Xml" : "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": { "type": "build", "version": "6.0.0-*" },
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
@@ -62,10 +62,10 @@ <h2>Script tag helper test</h2>
</script>

<!-- Globbed script tag with existing file -->
HtmlEncode[[]]<script src="HtmlEncode[[/styles/site.js]]"></script>
<script src="HtmlEncode[[/styles/site.js]]"></script>

<!-- Globbed script tag with existing file and exclude -->
HtmlEncode[[]]<script src="HtmlEncode[[/styles/site.js]]"></script><script src="HtmlEncode[[/styles/sub/site2.js]]"></script>
<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 @@ <h2>Script tag helper test</h2>
</script>

<!-- Globbed script tag with comma separated include pattern -->
HtmlEncode[[]]<script src="HtmlEncode[[/styles/site.js]]"></script><script src="HtmlEncode[[/styles/sub/site2.js]]"></script><script src="HtmlEncode[[/styles/sub/site3.js]]"></script>
<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 @@ <h2>Script tag helper test</h2>
</script>

<!-- Globbed script tag with existing files and version -->
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>
<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 -->
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/site.js?v=jx1PJjLX32-xgQQx2BxnckU9QH9DVKkm4-M5bSK869I]]"></script><script src="HtmlEncode[[/styles/sub/site2.js?v=pwJaxaQxnb-rPAdF2JlAp4xiPNq1XuJFd6TyOOfNF-0]]"></script>
</body>
</html>
1 change: 0 additions & 1 deletion test/Microsoft.AspNet.Mvc.FunctionalTests/project.json
Original file line number Diff line number Diff line change
@@ -44,7 +44,6 @@
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"ModelBindingWebSite": "1.0.0",
"MvcSample.Web": "1.0.0",
"PrecompilationWebSite": "1.0.0",
1 change: 0 additions & 1 deletion test/Microsoft.AspNet.Mvc.IntegrationTests/project.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@
"type": "build"
},
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
8 changes: 5 additions & 3 deletions test/Microsoft.AspNet.Mvc.Localization.Test/project.json
Original file line number Diff line number Diff line change
@@ -4,11 +4,13 @@
},
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.Localization": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
"Microsoft.AspNet.Mvc.TestCommon": {
"version": "6.0.0-*",
"type": "build"
},
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
6 changes: 4 additions & 2 deletions test/Microsoft.AspNet.Mvc.Razor.Host.Test/project.json
Original file line number Diff line number Diff line change
@@ -6,10 +6,12 @@
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
"Microsoft.AspNet.Mvc.Razor": "6.0.0-*",
"Microsoft.AspNet.Mvc.Razor.Host": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": {
"version": "6.0.0-*",
"type": "build"
},
"Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-*",
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
1 change: 0 additions & 1 deletion test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewTest.cs
Original file line number Diff line number Diff line change
@@ -914,7 +914,6 @@ public async Task RenderAsync_ExecutesNestedLayoutsWithNestedSections()
"]]BodyContent" +
"foo-content" +
Environment.NewLine +
"HtmlEncode[[]]" +
Environment.NewLine;

var page = new TestableRazorPage(v =>
3 changes: 1 addition & 2 deletions test/Microsoft.AspNet.Mvc.Razor.Test/project.json
Original file line number Diff line number Diff line change
@@ -14,9 +14,8 @@
"type": "build"
},
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"Microsoft.Dnx.Runtime": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
Original file line number Diff line number Diff line change
@@ -45,15 +45,15 @@ public static TheoryData<object, Type, Func<object>, NameAndId, string> Generate
modelWithNull,
modelWithText,
};
var noneSelected = "<option>HtmlEncode[[]]</option>" + Environment.NewLine +
var noneSelected = "<option></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>HtmlEncode[[]]</option>" + Environment.NewLine +
var innerSelected = "<option></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>HtmlEncode[[]]</option>" + Environment.NewLine +
var outerSelected = "<option></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;
Original file line number Diff line number Diff line change
@@ -48,35 +48,32 @@ public static TheoryData<object, Type, object, NameAndId, string> TestDataSet
{
{ null, typeof(Model), null,
new NameAndId("Text", "Text"),
Environment.NewLine + "HtmlEncode[[]]" },
Environment.NewLine },

{ modelWithNull, typeof(Model), modelWithNull.Text,
new NameAndId("Text", "Text"),
Environment.NewLine + "HtmlEncode[[]]"},
Environment.NewLine },
{ 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 + "HtmlEncode[[]]" },

Environment.NewLine },
{ 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 + "HtmlEncode[[]]" },

Environment.NewLine },
{ 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 + "HtmlEncode[[]]" },

Environment.NewLine },
{ models, typeof(NestedModel), models[1].NestedModel.Text,
new NameAndId("[1].NestedModel.Text", "z1__NestedModel_Text"),
Environment.NewLine + "HtmlEncode[[inner text]]" },
1 change: 0 additions & 1 deletion test/Microsoft.AspNet.Mvc.TagHelpers.Test/project.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
},
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ public void ActionLink_GeneratesLink_WithExpectedValues(
GetRouteValuesAsString(routeValues),
fragment,
GetHtmlAttributesAsString(htmlAttributes));
expectedLink = expectedLink.Replace("HtmlEncode[[]]", "");
expectedLink = expectedLink.Replace("HtmlEncode[[]]", string.Empty);

var urlHelper = new Mock<IUrlHelper>();
urlHelper.Setup(h => h.Action(It.IsAny<UrlActionContext>()))
@@ -122,7 +122,7 @@ public void RouteLink_GeneratesLink_WithExpectedValues(
GetRouteValuesAsString(routeValues),
fragment,
GetHtmlAttributesAsString(htmlAttributes));
expectedLink = expectedLink.Replace("HtmlEncode[[]]", "");
expectedLink = expectedLink.Replace("HtmlEncode[[]]", string.Empty);

var urlHelper = new Mock<IUrlHelper>();
urlHelper
Original file line number Diff line number Diff line change
@@ -72,8 +72,7 @@ public static TheoryData<object, string> EncodeObjectTestData
var data = new TheoryData<object, string>
{
{ null, string.Empty },
// Object overload does not special case the empty string.
{ string.Empty, "HtmlEncode[[]]" },
{ string.Empty, string.Empty },
{ "<\">", "HtmlEncode[[<\">]]" },
{ "<br />", "HtmlEncode[[<br />]]" },
{ "<b>bold</b>", "HtmlEncode[[<b>bold</b>]]" },
3 changes: 1 addition & 2 deletions test/Microsoft.AspNet.Mvc.ViewFeatures.Test/project.json
Original file line number Diff line number Diff line change
@@ -16,9 +16,8 @@
},
"Microsoft.AspNet.Testing": "1.0.0-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Microsoft.Extensions.DiagnosticAdapter": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {

0 comments on commit ff91e79

Please sign in to comment.