diff --git a/.travis.yml b/.travis.yml index 65b9f21ec2..90281b8fe4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: csharp sudo: false mono: - - 3.12.0 + - alpha script: - - ./build.sh --quiet verify \ No newline at end of file + - ./build.sh --quiet verify diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/DefaultApplicationModelProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/DefaultApplicationModelProviderTest.cs index 3ba65dbdcf..bfffb64a77 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/DefaultApplicationModelProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ApplicationModel/DefaultApplicationModelProviderTest.cs @@ -726,11 +726,12 @@ namespace Microsoft.AspNet.Mvc.ApplicationModels // Assert Assert.Equal(2, actions.Count()); + // OrderBy is used because the order of the results may very depending on the platform / client. var action = Assert.Single(actions, a => a.AttributeRouteModel.Template == "Products"); - Assert.Equal(new string[] { "GET", "POST" }, action.HttpMethods); + Assert.Equal(new [] { "GET", "POST" }, action.HttpMethods.OrderBy(key => key, StringComparer.Ordinal)); action = Assert.Single(actions, a => a.AttributeRouteModel.Template == "v2/Products"); - Assert.Equal(new string[] { "GET", "POST" }, action.HttpMethods); + Assert.Equal(new [] { "GET", "POST" }, action.HttpMethods.OrderBy(key => key, StringComparer.Ordinal)); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ByteArrayModelBinderTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ByteArrayModelBinderTests.cs index 939314bcb3..9a88a3673d 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ByteArrayModelBinderTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/ByteArrayModelBinderTests.cs @@ -65,9 +65,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test public async Task BindModelAddsModelErrorsOnInvalidCharacters() { // Arrange - var expected = TestPlatformHelper.IsMono ? - "Invalid length." : - "The value '\"Fys1\"' is not valid for foo."; + var expected = "The value '\"Fys1\"' is not valid for foo."; var valueProvider = new SimpleHttpValueProvider() { diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/DefaultObjectValidatorTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/DefaultObjectValidatorTests.cs index 7c41f25e48..3ccac28d46 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/DefaultObjectValidatorTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBinding/Validation/DefaultObjectValidatorTests.cs @@ -106,7 +106,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation if (!TestPlatformHelper.IsMono) { // In Mono this throws a NullRef Exception. - // Should be investigated - https://github.com/aspnet/Mvc/issues/1261 + // https://github.com/aspnet/External/issues/23 yield return new object[] { new Dictionary { { "Joe", new Person() } , { "Mark", new Person() } }, @@ -275,10 +275,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation typeof(Uri), new List() { typeof(Uri) } }; - yield return new object[] { new Dictionary { - { "values", new Uri("/api/values", UriKind.Relative) }, - { "hello", new Uri("/api/hello", UriKind.Relative) } - }, typeof(Dictionary), new List() { typeof(Uri) } }; + + // https://github.com/aspnet/External/issues/23 + if (!TestPlatformHelper.IsMono) + { + yield return new object[] { new Dictionary { + { "values", new Uri("/api/values", UriKind.Relative) }, + { "hello", new Uri("/api/hello", UriKind.Relative) } + }, typeof(Dictionary), new List() { typeof(Uri) } }; + } } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBindingHelperTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBindingHelperTest.cs index 4b67017478..87018515af 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ModelBindingHelperTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ModelBindingHelperTest.cs @@ -10,7 +10,6 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ModelBinding.Validation; -using Microsoft.AspNet.Testing; using Moq; using Xunit; @@ -51,8 +50,8 @@ namespace Microsoft.AspNet.Mvc.Test public async Task TryUpdateModel_ReturnsFalse_IfModelValidationFails() { // Arrange - var expectedMessage = TestPlatformHelper.IsMono ? "The field MyProperty is invalid." : - "The MyProperty field is required."; + // Mono issue - https://github.com/aspnet/External/issues/19 + var expectedMessage = PlatformNormalizer.NormalizeContent("The MyProperty field is required."); var binders = new IModelBinder[] { new TypeConverterModelBinder(), diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ObjectResultTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ObjectResultTests.cs index b7278044af..e5ded90190 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ObjectResultTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ObjectResultTests.cs @@ -11,6 +11,7 @@ using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.Xml; using Microsoft.AspNet.Routing; +using Microsoft.AspNet.Testing.xunit; using Microsoft.AspNet.WebUtilities; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; @@ -583,7 +584,9 @@ namespace Microsoft.AspNet.Mvc.Core.Test.ActionResults response.VerifySet(resp => resp.ContentType = expectedResponseContentType); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "application/xml; charset=utf-8")] // Chrome & Opera [InlineData("text/html, application/xhtml+xml, */*", @@ -621,7 +624,9 @@ namespace Microsoft.AspNet.Mvc.Core.Test.ActionResults response.VerifySet(resp => resp.ContentType = expectedResponseContentType); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("application/xml;q=0.9,text/plain;q=0.5", "application/xml; charset=utf-8", false)] [InlineData("application/xml;q=0.9,*/*;q=0.5", "application/json; charset=utf-8", false)] [InlineData("application/xml;q=0.9,text/plain;q=0.5", "application/xml; charset=utf-8", true)] diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/FilePathResultTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/FilePathResultTest.cs index 20b5cded96..3c887f4d1a 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/FilePathResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/FilePathResultTest.cs @@ -10,6 +10,7 @@ using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Routing; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Microsoft.Net.Http.Headers; using Moq; @@ -30,7 +31,9 @@ namespace Microsoft.AspNet.Mvc Assert.Equal(path, result.FileName); } - [Fact] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2727 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ExecuteResultAsync_FallsbackToStreamCopy_IfNoIHttpSendFilePresent() { // Arrange @@ -85,7 +88,9 @@ namespace Microsoft.AspNet.Mvc Assert.Equal("FilePathResultTestFile contents", contents); } - [Fact] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2727 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ExecuteResultAsync_CallsSendFileAsync_IfIHttpSendFilePresent() { // Arrange @@ -113,7 +118,9 @@ namespace Microsoft.AspNet.Mvc sendFileMock.Verify(); } - [Fact] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2727 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ExecuteResultAsync_SetsSuppliedContentTypeAndEncoding() { // Arrange @@ -143,7 +150,9 @@ namespace Microsoft.AspNet.Mvc Assert.Equal(expectedContentType, httpContext.Response.ContentType); } - [Fact] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2727 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ExecuteResultAsync_WorksWithAbsolutePaths_UsingBackSlash() { // Arrange @@ -174,7 +183,9 @@ namespace Microsoft.AspNet.Mvc Assert.Equal("FilePathResultTestFile contents", contents); } - [Fact] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2727 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ExecuteResultAsync_WorksWithAbsolutePaths_UsingForwardSlash() { // Arrange @@ -434,7 +445,9 @@ namespace Microsoft.AspNet.Mvc Assert.Equal(path, normalizedPath); } - [Theory] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2727 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("C:\\Folder\\SubFolder\\File.txt")] [InlineData("C:/Folder/SubFolder/File.txt")] [InlineData("\\\\NetworkLocation\\Folder\\SubFolder\\File.txt")] @@ -454,7 +467,9 @@ namespace Microsoft.AspNet.Mvc Assert.True(isRooted); } - [Theory] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2727 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("FilePathResultTestFile.txt")] [InlineData("/FilePathResultTestFile.txt")] [InlineData("\\FilePathResultTestFile.txt")] diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/JsonOutputFormatterTests.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/JsonOutputFormatterTests.cs index 4cf83dc3ed..a404393b94 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/JsonOutputFormatterTests.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/JsonOutputFormatterTests.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; +using Microsoft.AspNet.Testing; using Microsoft.Net.Http.Headers; using Moq; using Newtonsoft.Json; @@ -133,15 +134,22 @@ namespace Microsoft.AspNet.Mvc.Core.Test.Formatters { get { - return new TheoryData + var data = new TheoryData { { "This is a test 激光這兩個字是甚麼意思 string written using utf-8", "utf-8", true }, { "This is a test 激光這兩個字是甚麼意思 string written using utf-16", "utf-16", true }, { "This is a test 激光這兩個字是甚麼意思 string written using utf-32", "utf-32", false }, { "This is a test 激光這兩個字是甚麼意思 string written using shift_jis", "shift_jis", false }, { "This is a test æøå string written using iso-8859-1", "iso-8859-1", false }, - { "This is a test 레이저 단어 뜻 string written using iso-2022-kr", "iso-2022-kr", false }, }; + + if (!TestPlatformHelper.IsMono) + { + // Mono issue - https://github.com/aspnet/External/issues/28 + data.Add("This is a test 레이저 단어 뜻 string written using iso-2022-kr", "iso-2022-kr", false); + } + + return data; } } diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/JsonResultTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/JsonResultTest.cs index cd5d36b50c..e22edf33f3 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/JsonResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/JsonResultTest.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Generic; using System.IO; using System.Text; using System.Threading.Tasks; @@ -20,9 +21,6 @@ namespace Microsoft.AspNet.Mvc private static readonly byte[] _abcdUTF8Bytes = new byte[] { 123, 34, 102, 111, 111, 34, 58, 34, 97, 98, 99, 100, 34, 125 }; - private static readonly byte[] _abcdIndentedUTF8Bytes - = new byte[] { 123, 13, 10, 32, 32, 34, 102, 111, 111, 34, 58, 32, 34, 97, 98, 99, 100, 34, 13, 10, 125 }; - [Fact] public async Task ExecuteResultAsync_UsesDefaultContentType_IfNoContentTypeSpecified() { @@ -88,11 +86,25 @@ namespace Microsoft.AspNet.Mvc Assert.Equal("text/json; charset=us-ascii", context.Response.ContentType); } + private static List AbcdIndentedUTF8Bytes + { + get + { + var bytes = new List(); + bytes.Add(123); + bytes.AddRange(Encoding.UTF8.GetBytes(Environment.NewLine)); + bytes.AddRange(new byte[] { 32, 32, 34, 102, 111, 111, 34, 58, 32, 34, 97, 98, 99, 100, 34 }); + bytes.AddRange(Encoding.UTF8.GetBytes(Environment.NewLine)); + bytes.Add(125); + return bytes; + } + } + [Fact] public async Task ExecuteResultAsync_UsesPassedInSerializerSettings() { // Arrange - var expected = _abcdIndentedUTF8Bytes; + var expected = AbcdIndentedUTF8Bytes; var context = GetHttpContext(); var actionContext = new ActionContext(context, new RouteData(), new ActionDescriptor()); diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/ModelBinding/Metadata/DataAnnotationsMetadataProviderTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/ModelBinding/Metadata/DataAnnotationsMetadataProviderTest.cs index a9f6e83d94..1e2ca5c69e 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/ModelBinding/Metadata/DataAnnotationsMetadataProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/ModelBinding/Metadata/DataAnnotationsMetadataProviderTest.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Linq; using Microsoft.AspNet.Mvc.ModelBinding.Validation; using Xunit; @@ -538,7 +539,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Metadata provider.GetDisplayMetadata(context); // Assert - Assert.Equal(expectedKeyValuePairs, context.DisplayMetadata.EnumDisplayNamesAndValues); + // OrderBy is used because the order of the results may very depending on the platform / client. + Assert.Equal( + expectedKeyValuePairs?.OrderBy(item => item.Key, StringComparer.Ordinal), + context.DisplayMetadata.EnumDisplayNamesAndValues?.OrderBy(item => item.Key, StringComparer.Ordinal)); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/ModelBinding/Validation/CompareAttributeAdapterTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/ModelBinding/Validation/CompareAttributeAdapterTest.cs index c96e5e94a5..c33d836551 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/ModelBinding/Validation/CompareAttributeAdapterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/ModelBinding/Validation/CompareAttributeAdapterTest.cs @@ -31,7 +31,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation // Assert var rule = Assert.Single(rules); - Assert.Equal("'MyPropertyDisplayName' and 'OtherPropertyDisplayName' do not match.", rule.ErrorMessage); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent( + "'MyPropertyDisplayName' and 'OtherPropertyDisplayName' do not match."), + rule.ErrorMessage); } [Fact] @@ -52,7 +56,10 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation // Assert var rule = Assert.Single(rules); - Assert.Equal("'MyProperty' and 'OtherProperty' do not match.", rule.ErrorMessage); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent("'MyProperty' and 'OtherProperty' do not match."), + rule.ErrorMessage); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/DefaultEditorTemplatesTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/DefaultEditorTemplatesTest.cs index 997c8ae3ec..88b650aa25 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/DefaultEditorTemplatesTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/DefaultEditorTemplatesTest.cs @@ -589,12 +589,13 @@ Environment.NewLine; public void Editor_FindsCorrectDateOrTimeTemplate(string dataTypeName, string editFormatString, string expected) { // Arrange - var expectedInput = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expectedInput = PlatformNormalizer.NormalizeContent( ""; + "]]\" value=\"HtmlEncode[[" + expected + "]]\" />"); var offset = TimeSpan.FromHours(0); var model = new DateTimeOffset( @@ -641,12 +642,13 @@ Environment.NewLine; public void Editor_AppliesRfc3339(string dataTypeName, string editFormatString, string expected) { // Arrange - var expectedInput = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expectedInput = PlatformNormalizer.NormalizeContent( ""; + "]]\" value=\"HtmlEncode[[" + expected + "]]\" />"); // Place DateTime-local value in current timezone. var offset = string.Equals("", dataTypeName) ? DateTimeOffset.Now.Offset : TimeSpan.FromHours(0); @@ -698,12 +700,13 @@ Environment.NewLine; public void Editor_AppliesNonDefaultEditFormat(string dataTypeName, Html5DateRenderingMode renderingMode) { // Arrange - var expectedInput = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expectedInput = PlatformNormalizer.NormalizeContent( ""; + "]]\" value=\"HtmlEncode[[Formatted as 2000-01-02T03:04:05.0600000+00:00]]\" />"); var offset = TimeSpan.FromHours(0); var model = new DateTimeOffset( diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperCheckboxTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperCheckboxTest.cs index bc7b08458f..3fbb87512b 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperCheckboxTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperCheckboxTest.cs @@ -17,11 +17,12 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxOverridesCalculatedValuesWithValuesFromHtmlAttributes() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @""; + @"value=""HtmlEncode[[false]]"" />"); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData()); // Act @@ -37,11 +38,12 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxExplicitParametersOverrideDictionary_ForValueInModel() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @""; + @"value=""HtmlEncode[[false]]"" />"); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData()); @@ -88,11 +90,12 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxCheckedWithOnlyName_GeneratesExpectedValue() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @""; + @"value=""HtmlEncode[[true]]"" />"); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData()); // Act @@ -106,10 +109,11 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxUsesAttemptedValueFromModelState() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @"" + - @""; + @""); var valueProviderResult = new ValueProviderResult("false", "false", CultureInfo.InvariantCulture); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData()); helper.ViewData.ModelState.SetModelValue("Property1", valueProviderResult); @@ -289,9 +293,11 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxGeneratesUnobtrusiveValidationAttributes() { // Arrange - var expected = @"" + - @""; + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( + @"" + + @""); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetModelWithValidationViewData()); // Act @@ -305,12 +311,13 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxReplacesUnderscoresInHtmlAttributesWithDashes() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @""; + @"name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />"); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData()); var htmlAttributes = new { Property1_Property3 = "Property3ObjValue" }; @@ -363,11 +370,12 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxInTemplate_WithEmptyExpression_GeneratesExpectedValue() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @""; + @"value=""HtmlEncode[[false]]"" />"); var helper = DefaultTemplatesUtilities.GetHtmlHelper(model: false); var attributes = new Dictionary { { "Property3", "Property3Value" } }; helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; @@ -383,12 +391,13 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxWithComplexExpressionsEvaluatesValuesInViewDataDictionary() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @""; + @" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />"); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetModelWithValidationViewData()); // Act @@ -402,10 +411,11 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxForWithNullContainer_TreatsBooleanAsFalse() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @"" + - @""; + @""); var viewData = GetTestModelViewData(); var helper = DefaultTemplatesUtilities.GetHtmlHelper(viewData); var valueProviderResult = new ValueProviderResult("false", "false", CultureInfo.InvariantCulture); @@ -424,10 +434,11 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxForWithNonNullContainer_UsesPropertyValue(bool value, string expectedChecked) { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @"" + - @""; + @""); expected = string.Format(expected, expectedChecked); var viewData = GetTestModelViewData(); @@ -449,11 +460,12 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxForOverridesCalculatedParametersWithValuesFromHtmlAttributes() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @""; + @"value=""HtmlEncode[[false]]"" />"); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData()); // Act @@ -467,9 +479,11 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxForGeneratesUnobtrusiveValidationAttributes() { // Arrange - var expected = @"" + - @""; + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( + @"" + + @""); var metadataProvider = TestModelMetadataProvider.CreateDefaultProvider(); var viewDataDictionary = new ViewDataDictionary(metadataProvider) { @@ -490,10 +504,11 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxFor_UsesModelStateAttemptedValue(string attemptedValue, string expectedChecked) { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @"" + - @""; + @""); expected = string.Format(expected, expectedChecked); var viewData = GetTestModelViewData(); @@ -513,11 +528,12 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxFor_WithObjectAttribute_MapsUnderscoresInNamesToDashes() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @""; + @"name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />"); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData()); var htmlAttributes = new { Property1_Property3 = "Property3ObjValue" }; @@ -532,11 +548,12 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxFor_WithAttributeDictionary_GeneratesExpectedAttributes() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @""; + @"name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />"); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData()); var attributes = new Dictionary { { "Property3", "Property3Value" } }; @@ -551,11 +568,12 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxForInTemplate_GeneratesExpectedValue() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @""; + @"value=""HtmlEncode[[false]]"" />"); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData()); helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; var attributes = new Dictionary { { "Property3", "PropValue" } }; @@ -571,11 +589,12 @@ namespace Microsoft.AspNet.Mvc.Rendering public void CheckBoxFor_WithComplexExpressions_DoesNotUseValuesFromViewDataDictionary() { // Arrange - var expected = + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( @""; + @"type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />"); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetModelWithValidationViewData()); // Act diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperHiddenTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperHiddenTest.cs index ebd1824f61..192f3133de 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperHiddenTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperHiddenTest.cs @@ -433,8 +433,10 @@ namespace Microsoft.AspNet.Mvc.Rendering public void HiddenGeneratesUnobtrusiveValidation() { // Arrange - var expected = @""; + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( + @""); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetViewDataWithModelStateAndModelAndViewDataValues()); // Act @@ -686,8 +688,10 @@ namespace Microsoft.AspNet.Mvc.Rendering public void HiddenFor_GeneratesUnobtrusiveValidationAttributes() { // Arrange - var expected = @""; + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( + @""); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetViewDataWithErrors()); // Act diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperPasswordTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperPasswordTest.cs index d393c978c6..30ea2c767c 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperPasswordTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperPasswordTest.cs @@ -160,8 +160,10 @@ namespace Microsoft.AspNet.Mvc.Rendering public void PasswordGeneratesUnobtrusiveValidation() { // Arrange - var expected = @""; + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( + @""); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetViewDataWithModelStateAndModelAndViewDataValues()); // Act @@ -266,8 +268,10 @@ namespace Microsoft.AspNet.Mvc.Rendering public void PasswordFor_GeneratesUnobtrusiveValidationAttributes() { // Arrange - var expected = @""; + // Mono issue - https://github.com/aspnet/External/issues/19 + var expected = PlatformNormalizer.NormalizeContent( + @""); var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetViewDataWithErrors()); // Act diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperSelectTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperSelectTest.cs index ca432075bc..ed2340300c 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperSelectTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/Rendering/HtmlHelperSelectTest.cs @@ -1468,7 +1468,10 @@ namespace Microsoft.AspNet.Mvc.Rendering var result = htmlHelper.GetEnumSelectList(type); // Assert - VerifySelectList(expected, result); + // OrderBy is used because the order of the results may very depending on the platform / client. + VerifySelectList( + expected.OrderBy(item => item.Text, StringComparer.Ordinal), + result.OrderBy(item => item.Text, StringComparer.Ordinal)); } private static string GetExpectedSelectElement(SelectSources source, bool allowMultiple) diff --git a/test/Microsoft.AspNet.Mvc.Extensions.Test/ViewComponents/JsonViewComponentResultTest.cs b/test/Microsoft.AspNet.Mvc.Extensions.Test/ViewComponents/JsonViewComponentResultTest.cs index 76e469b1f4..ab03d67a38 100644 --- a/test/Microsoft.AspNet.Mvc.Extensions.Test/ViewComponents/JsonViewComponentResultTest.cs +++ b/test/Microsoft.AspNet.Mvc.Extensions.Test/ViewComponents/JsonViewComponentResultTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.IO; using System.Text; using Microsoft.AspNet.Http; @@ -36,7 +37,9 @@ namespace Microsoft.AspNet.Mvc result.Execute(viewComponentContext); // Assert - Assert.Equal("{\r\n \"foo\": \"abcd\"\r\n}", Encoding.UTF8.GetString(buffer.ToArray())); + Assert.Equal( + $"{{{Environment.NewLine} \"foo\": \"abcd\"{Environment.NewLine}}}", + Encoding.UTF8.GetString(buffer.ToArray())); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ApiExplorerTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ApiExplorerTest.cs index be1958ee11..d1e0183fe9 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ApiExplorerTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ApiExplorerTest.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.Xml; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Newtonsoft.Json; using Xunit; @@ -568,7 +569,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(type, description.ResponseType); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ApiExplorer_ResponseContentType_Unset() { // Arrange @@ -644,7 +647,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Empty(formats); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("Controller", "text/xml", "Microsoft.AspNet.Mvc.Xml.XmlDataContractSerializerOutputFormatter")] [InlineData("Action", "application/json", "Microsoft.AspNet.Mvc.JsonOutputFormatter")] public async Task ApiExplorer_ResponseContentType_OverrideOnAction( diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ConsumesAttributeTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ConsumesAttributeTests.cs index e57a7d7121..e01dbaf904 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ConsumesAttributeTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ConsumesAttributeTests.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using ActionConstraintsWebSite; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Newtonsoft.Json; using Xunit; @@ -56,10 +57,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); Assert.Equal(typeof(AmbiguousActionException).FullName, exception.ExceptionType); + // Mono issue - https://github.com/aspnet/External/issues/19 Assert.Equal( - "Multiple actions matched. The following actions matched route data and had all constraints "+ - "satisfied:____ActionConstraintsWebSite.ConsumesAttribute_NoFallBackActionController."+ - "CreateProduct__ActionConstraintsWebSite.ConsumesAttribute_NoFallBackActionController.CreateProduct", + "Multiple actions matched. The following actions matched route data and had all constraints " + + "satisfied:" + PlatformNormalizer.GetNewLinesAsUnderscores(2) + "ActionConstraintsWebSite." + + "ConsumesAttribute_NoFallBackActionController." + + "CreateProduct" + PlatformNormalizer.GetNewLinesAsUnderscores(1) + "ActionConstraintsWebSite." + + "ConsumesAttribute_NoFallBackActionController.CreateProduct", exception.ExceptionMessage); } @@ -131,7 +135,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(expectedString, product.SampleString); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task DerivedClassLevelAttribute_OveridesBaseClassLevel() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ContentNegotiationTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ContentNegotiationTest.cs index 13d52edd07..5d50f0070d 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ContentNegotiationTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ContentNegotiationTest.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using ContentNegotiationWebSite; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc.Xml; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Xunit; @@ -48,7 +49,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests var server = TestHelper.CreateServer(_app, SiteName, _configureServices); var client = server.CreateClient(); var expectedContentType = MediaTypeHeaderValue.Parse("application/json;charset=utf-8"); - var expectedBody = "{\r\n \"Name\": \"My name\",\r\n \"Address\": \"My address\"\r\n}"; + var expectedBody = $"{{{Environment.NewLine} \"Name\": \"My name\",{Environment.NewLine}" + + $" \"Address\": \"My address\"{Environment.NewLine}}}"; // Act var response = await client.GetAsync("http://localhost/Normal/MultipleAllowedContentTypes"); @@ -112,7 +114,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(expectedOutput, actual); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ProducesAttribute_WithTypeAndContentType_UsesContentType() { // Arrange @@ -319,7 +323,9 @@ END:VCARD Assert.Equal(expectedBody, body); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task XmlFormatter_SupportedMediaType_DoesNotChangeAcrossRequests() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ErrorPageTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ErrorPageTests.cs index 81350ddaf8..cfdf7883ab 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ErrorPageTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ErrorPageTests.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.IO; using System.Net; using System.Net.Http.Headers; using System.Threading.Tasks; @@ -62,7 +63,10 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); var content = await response.Content.ReadAsStringAsync(); - Assert.Contains(@"Views\ErrorFromViewImports\_ViewImports.cshtml", content); + Assert.Contains( + PlatformNormalizer.NormalizePath(@"Views\ErrorFromViewImports\_ViewImports.cshtml"), + content); + Assert.Contains(expectedMessage, content); } } diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/FileResultTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/FileResultTests.cs index a2ad33b1a2..942f215e7d 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/FileResultTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/FileResultTests.cs @@ -5,6 +5,7 @@ using System; using System.Net; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Xunit; @@ -16,8 +17,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests private readonly Action _app = new FilesWebSite.Startup().Configure; private readonly Action _configureServices = new FilesWebSite.Startup().ConfigureServices; - - [Fact] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2727 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task FileFromDisk_CanBeEnabled_WithMiddleware() { // Arrange @@ -38,7 +40,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal("This is a sample text file", body); } - [Fact] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2727 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task FileFromDisk_ReturnsFileWithFileName() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/FiltersTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/FiltersTest.cs index 3d3efec7f2..bcbbc8131c 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/FiltersTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/FiltersTest.cs @@ -9,6 +9,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc.Xml; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Xunit; @@ -505,7 +506,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Action has two Exception filters. // Verifies that the second Exception Filter was not executed. - [Fact] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2757 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ExceptionFilterShortCircuitsAnotherExceptionFilter() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/HtmlGenerationTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/HtmlGenerationTest.cs index a27f4c0573..6b00521a4d 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/HtmlGenerationTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/HtmlGenerationTest.cs @@ -12,6 +12,7 @@ using System.Threading.Tasks; using HtmlGenerationWebSite; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc.TagHelpers; +using Microsoft.AspNet.Testing; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.WebEncoders; using Xunit; @@ -54,6 +55,12 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests [InlineData("Input", null)] public async Task HtmlGenerationWebSite_GeneratesExpectedResults(string action, string antiforgeryPath) { + // This uses FileVersionProvider which uses Uri.TryCreate - https://github.com/aspnet/External/issues/21 + if (TestPlatformHelper.IsMono && (action == "Link" || action == "Script" || action == "Image")) + { + return; + } + // Arrange var server = TestHelper.CreateServer(_app, SiteName, _configureServices); var client = server.CreateClient(); @@ -77,7 +84,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests #if GENERATE_BASELINES ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent); #else - Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expectedContent.Trim()), + responseContent, + ignoreLineEndingDifferences: true); #endif } else @@ -89,7 +100,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent); #else expectedContent = string.Format(expectedContent, forgeryToken); - Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expectedContent.Trim()), + responseContent, + ignoreLineEndingDifferences: true); #endif } } @@ -104,6 +119,12 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests [InlineData("Script", null)] public async Task HtmlGenerationWebSite_GenerateEncodedResults(string action, string antiforgeryPath) { + // This uses FileVersionProvider which uses Uri.TryCreate - https://github.com/aspnet/External/issues/21 + if (TestPlatformHelper.IsMono && (action == "Link" || action == "Script")) + { + return; + } + // Arrange var server = TestHelper.CreateServer(_app, SiteName, services => { @@ -133,7 +154,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests #if GENERATE_BASELINES ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent); #else - Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expectedContent.Trim()), + responseContent, + ignoreLineEndingDifferences: true); #endif } else @@ -145,7 +170,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent); #else expectedContent = string.Format(expectedContent, forgeryToken); - Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expectedContent.Trim()), + responseContent, + ignoreLineEndingDifferences: true); #endif } } @@ -188,7 +217,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent); #else expectedContent = string.Format(expectedContent, forgeryToken); - Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expectedContent.Trim()), + responseContent, + ignoreLineEndingDifferences: true); #endif } diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/HtmlHelperOptionsTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/HtmlHelperOptionsTest.cs index e1e2ad1315..79911fedb1 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/HtmlHelperOptionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/HtmlHelperOptionsTest.cs @@ -83,7 +83,11 @@ True"; var body = await client.GetStringAsync("http://localhost/HtmlHelperOptions/OverrideAppWideDefaultsInView"); // Assert - Assert.Equal(expected, body.Trim(), ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expected), + body.Trim(), + ignoreLineEndingDifferences: true); } } } diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/InlineConstraintTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/InlineConstraintTests.cs index 6e4785b7cf..972de79070 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/InlineConstraintTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/InlineConstraintTests.cs @@ -8,6 +8,7 @@ using System.Net.Http; using System.Threading.Tasks; using InlineConstraints; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing; using Microsoft.Framework.DependencyInjection; using Newtonsoft.Json; using Xunit; @@ -48,10 +49,14 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var exception = response.GetServerException(); - Assert.Equal("The view 'Index' was not found." + - " The following locations were searched:__/Areas/Users/Views/Home/Index.cshtml__" + - "/Areas/Users/Views/Shared/Index.cshtml__/Views/Shared/Index.cshtml.", - exception.ExceptionMessage); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + "The view 'Index' was not found." + + " The following locations were searched:" + PlatformNormalizer.GetNewLinesAsUnderscores(1) + + "/Areas/Users/Views/Home/Index.cshtml" + PlatformNormalizer.GetNewLinesAsUnderscores(1) + + "/Areas/Users/Views/Shared/Index.cshtml" + PlatformNormalizer.GetNewLinesAsUnderscores(1) + + "/Views/Shared/Index.cshtml.", + exception.ExceptionMessage); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/InputFormatterTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/InputFormatterTests.cs index 0b400a8dc4..d194829972 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/InputFormatterTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/InputFormatterTests.cs @@ -8,6 +8,7 @@ using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Newtonsoft.Json; using Xunit; @@ -21,7 +22,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests private readonly Action _configureServices = new FormatterWebSite.Startup().ConfigureServices; - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task CheckIfXmlInputFormatterIsBeingCalled() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/InputObjectValidationTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/InputObjectValidationTests.cs index 439e0ac5e8..92b516c486 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/InputObjectValidationTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/InputObjectValidationTests.cs @@ -10,6 +10,8 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.WebUtilities; +using Microsoft.AspNet.Testing; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Newtonsoft.Json; using Xunit; @@ -44,7 +46,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task CheckIfObjectIsDeserializedWithoutErrors() { // Arrange @@ -91,10 +95,13 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.Equal("The field Id must be between 1 and 2000.," + + // Mono issue - https://github.com/aspnet/External/issues/29 + Assert.Equal(PlatformNormalizer.NormalizeContent( + "The field Id must be between 1 and 2000.," + "The field Name must be a string or array type with a minimum length of '5'.," + "The field Alias must be a string with a minimum length of 3 and a maximum length of 15.," + - "The field Designation must match the regular expression '[0-9a-zA-Z]*'.", + "The field Designation must match the regular expression " + + (TestPlatformHelper.IsMono ? "[0-9a-zA-Z]*." : "'[0-9a-zA-Z]*'.")), await response.Content.ReadAsStringAsync()); } diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/JsonOutputFormatterTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/JsonOutputFormatterTests.cs index 2af52a2c22..a2064bf5c1 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/JsonOutputFormatterTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/JsonOutputFormatterTests.cs @@ -9,6 +9,7 @@ using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Newtonsoft.Json; using Xunit; @@ -50,7 +51,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(expectedBody, actualBody); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task SerializableErrorIsReturnedInExpectedFormat() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/LinkGenerationTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/LinkGenerationTests.cs index 2285f1838f..962a24d1ef 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/LinkGenerationTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/LinkGenerationTests.cs @@ -7,6 +7,7 @@ using System.Net.Http.Headers; using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing; using Microsoft.Framework.DependencyInjection; using Xunit; @@ -45,8 +46,10 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert Assert.Equal(HttpStatusCode.Redirect, response.StatusCode); - - Assert.Equal(expected, response.Headers.Location.ToString()); + // Location.ToString() in mono returns file://url. (https://github.com/aspnet/External/issues/21) + Assert.Equal( + TestPlatformHelper.IsMono ? new Uri(expected) : new Uri(expected, UriKind.Relative), + response.Headers.Location); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/LocalizationTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/LocalizationTest.cs index cb205b341b..c15576f728 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/LocalizationTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/LocalizationTest.cs @@ -7,6 +7,7 @@ using System.Reflection; using System.Threading.Tasks; using LocalizationWebSite; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing; using Microsoft.Framework.DependencyInjection; using Microsoft.Net.Http.Headers; using Xunit; @@ -42,14 +43,17 @@ mypartial "; yield return new[] { "fr", expected2 }; - var expected3 = + if (!TestPlatformHelper.IsMono) + { + // https://github.com/aspnet/Mvc/issues/2759 + var expected3 = @" index partial mypartial "; - yield return new[] { "na", expected3 }; - + yield return new[] { "!-invalid-!", expected3 }; + } } } diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ModelBindingTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ModelBindingTest.cs index 0727599e8c..5d795bc1eb 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ModelBindingTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ModelBindingTest.cs @@ -9,8 +9,11 @@ using System.Net; using System.Net.Http; using System.Reflection; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using ModelBindingWebSite.Models; using ModelBindingWebSite.ViewModels; @@ -791,14 +794,15 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests var json = JsonConvert.DeserializeObject>(response); // 8 is the value of MaxModelValidationErrors for the application being tested. + // Mono issue - https://github.com/aspnet/External/issues/19 Assert.Equal(8, json.Count); - Assert.Equal("The Field1 field is required.", json["Field1"]); - Assert.Equal("The Field2 field is required.", json["Field2"]); - Assert.Equal("The Field3 field is required.", json["Field3"]); - Assert.Equal("The Field4 field is required.", json["Field4"]); - Assert.Equal("The Field5 field is required.", json["Field5"]); - Assert.Equal("The Field6 field is required.", json["Field6"]); - Assert.Equal("The Field7 field is required.", json["Field7"]); + Assert.Equal(PlatformNormalizer.NormalizeContent("The Field1 field is required."), json["Field1"]); + Assert.Equal(PlatformNormalizer.NormalizeContent("The Field2 field is required."), json["Field2"]); + Assert.Equal(PlatformNormalizer.NormalizeContent("The Field3 field is required."), json["Field3"]); + Assert.Equal(PlatformNormalizer.NormalizeContent("The Field4 field is required."), json["Field4"]); + Assert.Equal(PlatformNormalizer.NormalizeContent("The Field5 field is required."), json["Field5"]); + Assert.Equal(PlatformNormalizer.NormalizeContent("The Field6 field is required."), json["Field6"]); + Assert.Equal(PlatformNormalizer.NormalizeContent("The Field7 field is required."), json["Field7"]); Assert.Equal("The maximum number of allowed model errors has been reached.", json[""]); } @@ -815,9 +819,10 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var json = JsonConvert.DeserializeObject>(response); Assert.Equal(3, json.Count); - Assert.Equal("The Field1 field is required.", json["Field1"]); - Assert.Equal("The Field2 field is required.", json["Field2"]); - Assert.Equal("The Field3 field is required.", json["Field3"]); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal(PlatformNormalizer.NormalizeContent("The Field1 field is required."), json["Field1"]); + Assert.Equal(PlatformNormalizer.NormalizeContent("The Field2 field is required."), json["Field2"]); + Assert.Equal(PlatformNormalizer.NormalizeContent("The Field3 field is required."), json["Field3"]); } [Fact] @@ -1256,13 +1261,15 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests var modelStateErrors = JsonConvert.DeserializeObject>>(body); Assert.Equal(2, modelStateErrors.Count); + // OrderBy is used because the order of the results may very depending on the platform / client. Assert.Equal(new[] { "The field Year must be between 1980 and 2034.", "Year is invalid" - }, modelStateErrors["Year"]); + }, modelStateErrors["Year"].OrderBy(item => item, StringComparer.Ordinal)); var vinError = Assert.Single(modelStateErrors["Vin"]); - Assert.Equal("The Vin field is required.", vinError); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal(PlatformNormalizer.NormalizeContent("The Vin field is required."), vinError); } [Fact] @@ -1336,7 +1343,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } #if DNX451 - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task UpdateVehicle_WithXml_BindsBodyServicesAndHeaders() { // Arrange @@ -1406,6 +1415,17 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests #if GENERATE_BASELINES ResourceFile.UpdateFile(_assembly, outputFile, expectedContent, responseContent); #else + // Mono issue - https://github.com/aspnet/External/issues/19 + expectedContent = PlatformNormalizer.NormalizeContent(expectedContent); + if (TestPlatformHelper.IsMono) + { + expectedContent = expectedContent.Replace( + "The field Year must be between 1980 and 2034.", + "Year is invalid"); + } + Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true); #endif } @@ -1442,7 +1462,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests #if GENERATE_BASELINES ResourceFile.UpdateFile(_assembly, outputFile, expectedContent, responseContent); #else - Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expectedContent), + responseContent, + ignoreLineEndingDifferences: true); #endif } @@ -1653,7 +1677,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests #if GENERATE_BASELINES ResourceFile.UpdateFile(_assembly, outputFile, expectedContent, responseContent); #else - Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expectedContent), + responseContent, + ignoreLineEndingDifferences: true); #endif } @@ -1696,7 +1724,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests #if GENERATE_BASELINES ResourceFile.UpdateFile(_assembly, outputFile, expectedContent, responseContent); #else - Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expectedContent), + responseContent, + ignoreLineEndingDifferences: true); #endif } diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ModelMetadataAttributeTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ModelMetadataAttributeTest.cs index 875339a26f..d441e7c61a 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ModelMetadataAttributeTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ModelMetadataAttributeTest.cs @@ -7,6 +7,7 @@ using System.Net.Http; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing; using Microsoft.Framework.DependencyInjection; using Newtonsoft.Json; using Xunit; @@ -60,10 +61,15 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(6, json.Count); Assert.Equal("CompanyName cannot be null or empty.", json["CompanyName"]); Assert.Equal("The field Price must be between 20 and 100.", json["Price"]); - Assert.Equal("The Category field is required.", json["Category"]); - Assert.Equal("The Contact Us field is required.", json["Contact"]); - Assert.Equal("The Detail2 field is required.", json["ProductDetails.Detail2"]); - Assert.Equal("The Detail3 field is required.", json["ProductDetails.Detail3"]); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal(PlatformNormalizer.NormalizeContent("The Category field is required."), json["Category"]); + Assert.Equal(PlatformNormalizer.NormalizeContent("The Contact Us field is required."), json["Contact"]); + Assert.Equal( + PlatformNormalizer.NormalizeContent("The Detail2 field is required."), + json["ProductDetails.Detail2"]); + Assert.Equal( + PlatformNormalizer.NormalizeContent("The Detail3 field is required."), + json["ProductDetails.Detail3"]); } [Fact] @@ -85,7 +91,10 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests var body = await response.Content.ReadAsStringAsync(); var json = JsonConvert.DeserializeObject>(body); Assert.Equal(1, json.Count); - Assert.Equal("The ProductDetails field is required.", json["ProductDetails"]); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent("The ProductDetails field is required."), + json["ProductDetails"]); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/MvcSampleTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/MvcSampleTests.cs index 9df93bdd77..e970578fa0 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/MvcSampleTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/MvcSampleTests.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc.Xml; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Xunit; @@ -111,7 +112,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); } - [Fact] + [ConditionalTheory] + // Mono.Xml2.XmlTextReader.ReadText is unable to read the XML. This is fixed in mono 4.3.0. + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task Home_CreateUser_ReturnsXmlBasedOnAcceptHeader() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/PrecompilationTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/PrecompilationTest.cs index 5c8cc5e377..980c2e2665 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/PrecompilationTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/PrecompilationTest.cs @@ -9,6 +9,7 @@ using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc.Razor.Precompilation; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Runtime; using PrecompilationWebSite; @@ -23,7 +24,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests private readonly Action _app = new Startup().Configure; private readonly Action _configureServices = new Startup().ConfigureServices; - [Fact] + [ConditionalTheory] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task PrecompiledView_RendersCorrectly() { // Arrange @@ -186,7 +188,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.StartsWith(expected, responseContent.Trim()); } - [Fact] + [ConditionalTheory] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task DeletingPrecompiledGlobalFile_PriorToFirstRequestToAView_CausesViewToBeRecompiled() { // Arrange @@ -230,7 +233,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } } - [Fact] + [ConditionalTheory] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task TagHelpersFromTheApplication_CanBeAdded() { // Arrange @@ -252,7 +256,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(expected, responseLines[1]); } - [Fact] + [ConditionalTheory] + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task TagHelpersFromTheApplication_CanBeRemoved() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/RemoteAttributeValidationTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/RemoteAttributeValidationTest.cs index e536ffc150..2b67b60d21 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/RemoteAttributeValidationTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/RemoteAttributeValidationTest.cs @@ -47,7 +47,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests #if GENERATE_BASELINES ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent); #else - Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expectedContent), + responseContent, + ignoreLineEndingDifferences: true); #endif } diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/RespectBrowserAcceptHeaderTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/RespectBrowserAcceptHeaderTests.cs index d8c34811e5..7e5ef1f5e8 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/RespectBrowserAcceptHeaderTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/RespectBrowserAcceptHeaderTests.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc.Xml; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Xunit; @@ -41,7 +42,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal("{\"Id\":10,\"Name\":\"John\"}", responseData); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("application/xml,*/*;0.2")] [InlineData("application/xml,*/*")] public async Task AllMediaRangeAcceptHeader_ProducesAttributeIsHonored(string acceptHeader) @@ -66,7 +69,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests XmlAssert.Equal(expectedResponseData, responseData); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("application/xml,*/*;0.2")] [InlineData("application/xml,*/*")] public async Task AllMediaRangeAcceptHeader_WithContentTypeHeader_ContentTypeIsHonored(string acceptHeader) diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ResponseCacheTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ResponseCacheTest.cs index 27f80eacd2..516ebf852c 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ResponseCacheTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ResponseCacheTest.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.Framework.DependencyInjection; @@ -29,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=100", data); + AssertHeaderEquals("public, max-age=100", data); data = Assert.Single(response.Headers.GetValues("Vary")); Assert.Equal("Accept", data); } @@ -58,7 +59,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal(expected, data); + AssertHeaderEquals(expected, data); } [Fact] @@ -74,12 +75,12 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response1.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=100", data); + AssertHeaderEquals("public, max-age=100", data); data = Assert.Single(response1.Headers.GetValues("Vary")); Assert.Equal("Accept", data); data = Assert.Single(response2.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=100", data); + AssertHeaderEquals("public, max-age=100", data); data = Assert.Single(response2.Headers.GetValues("Vary")); Assert.Equal("Accept", data); } @@ -96,7 +97,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=20", data); + AssertHeaderEquals("public, max-age=20", data); } [Fact] @@ -111,7 +112,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("no-store, no-cache", data); + AssertHeaderEquals("no-store, no-cache", data); } [Fact] @@ -128,7 +129,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests var data = Assert.Single(response.Headers.GetValues("Vary")); Assert.Equal("Accept", data); data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=10", data); + AssertHeaderEquals("public, max-age=10", data); IEnumerable pragmaValues; response.Headers.TryGetValues("Pragma", out pragmaValues); Assert.Null(pragmaValues); @@ -146,7 +147,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=40", data); + AssertHeaderEquals("public, max-age=40", data); } [Fact] @@ -177,7 +178,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=30", data); + AssertHeaderEquals("public, max-age=30", data); } [Fact] @@ -192,7 +193,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("max-age=30, private", data); + AssertHeaderEquals("max-age=30, private", data); } [Fact] @@ -207,7 +208,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("no-store, no-cache", data); + AssertHeaderEquals("no-store, no-cache", data); data = Assert.Single(response.Headers.GetValues("Pragma")); Assert.Equal("no-cache", data); } @@ -224,7 +225,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=30", data); + AssertHeaderEquals("public, max-age=30", data); data = Assert.Single(response.Headers.GetValues("Vary")); Assert.Equal("Accept", data); } @@ -241,7 +242,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=10", data); + AssertHeaderEquals("public, max-age=10", data); } [Fact] @@ -275,7 +276,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests var data = Assert.Single(response.Headers.GetValues("Vary")); Assert.Equal("Accept", data); data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=30", data); + AssertHeaderEquals("public, max-age=30", data); IEnumerable pragmaValues; response.Headers.TryGetValues("Pragma", out pragmaValues); Assert.Null(pragmaValues); @@ -294,7 +295,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=15", data); + AssertHeaderEquals("public, max-age=15", data); } [Fact] @@ -309,7 +310,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var data = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("max-age=30, private", data); + AssertHeaderEquals("max-age=30, private", data); } [Fact] @@ -339,7 +340,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var cacheControl = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=30", cacheControl); + AssertHeaderEquals("public, max-age=30", cacheControl); var vary = Assert.Single(response.Headers.GetValues("Vary")); Assert.Equal("Test", vary); } @@ -356,8 +357,16 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert var cacheControl = Assert.Single(response.Headers.GetValues("Cache-control")); - Assert.Equal("public, max-age=30", cacheControl); + AssertHeaderEquals("public, max-age=30", cacheControl); Assert.Throws(() => response.Headers.GetValues("Vary")); } + + private void AssertHeaderEquals(string expected, string actual) + { + // OrderBy is used because the order of the results may very depending on the platform / client. + Assert.Equal( + expected.Split(',').Select(p => p.Trim()).OrderBy(item => item, StringComparer.Ordinal), + actual.Split(',').Select(p => p.Trim()).OrderBy(item => item, StringComparer.Ordinal)); + } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/SerializableErrorTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/SerializableErrorTests.cs index 41b9bd0880..6bc15adad7 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/SerializableErrorTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/SerializableErrorTests.cs @@ -9,6 +9,8 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc.Xml; +using Microsoft.AspNet.Testing; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Xunit; @@ -20,9 +22,27 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests private readonly Action _app = new XmlFormattersWebSite.Startup().Configure; private readonly Action _configureServices = new XmlFormattersWebSite.Startup().ConfigureServices; + public static TheoryData AcceptHeadersData + { + get + { + var data = new TheoryData + { + "application/xml-xmlser" + }; + + // Mono issue - https://github.com/aspnet/External/issues/18 + if (!TestPlatformHelper.IsMono) + { + data.Add("application/xml-dcs"); + } + + return data; + } + } + [Theory] - [InlineData("application/xml-xmlser")] - [InlineData("application/xml-dcs")] + [MemberData(nameof(AcceptHeadersData))] public async Task ModelStateErrors_AreSerialized(string acceptHeader) { // Arrange @@ -43,7 +63,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests XmlAssert.Equal(expectedXml, responseData); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + // XmlSerializer test is disabled Mono.Xml2.XmlTextReader.ReadText is unable to read the XML. + // This is fixed in mono 4.3.0. + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("application/xml-xmlser")] [InlineData("application/xml-dcs")] public async Task PostedSerializableError_IsBound(string acceptHeader) @@ -67,7 +91,11 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests XmlAssert.Equal(expectedXml, responseData); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + // XmlSerializer test is disabled Mono.Xml2.XmlTextReader.ReadText is unable to read the XML. + // This is fixed in mono 4.3.0. + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("application/xml-xmlser")] [InlineData("application/xml-dcs")] public async Task IsReturnedInExpectedFormat(string acceptHeader) diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/TagHelpersTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/TagHelpersTest.cs index f4a6bdb2af..f4cc52b9a3 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/TagHelpersTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/TagHelpersTest.cs @@ -156,7 +156,11 @@ page:root-content" #if GENERATE_BASELINES ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent); #else - Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expectedContent), + responseContent, + ignoreLineEndingDifferences: true); #endif } @@ -224,7 +228,11 @@ page:root-content" #if GENERATE_BASELINES ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent); #else - Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent(expectedContent), + responseContent, + ignoreLineEndingDifferences: true); #endif } } diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/TempDataTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/TempDataTest.cs index 473e1a7938..499c0f4069 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/TempDataTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/TempDataTest.cs @@ -8,6 +8,7 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Microsoft.Net.Http.Headers; using Xunit; @@ -74,7 +75,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal("Foo", body); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task Redirect_RetainsTempData_EvenIfAccessed() { // Arrange @@ -142,7 +145,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal("Foo", body); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task TempData_ValidTypes_RoundTripProperly() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/TryValidateModelTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/TryValidateModelTest.cs index 5b335f3b68..e52c24d4b9 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/TryValidateModelTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/TryValidateModelTest.cs @@ -3,11 +3,13 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Net; using System.Net.Http; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing; using Microsoft.Framework.DependencyInjection; using Newtonsoft.Json; using Xunit; @@ -42,9 +44,15 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(4, json.Count); Assert.Equal("CompanyName cannot be null or empty.", json["CompanyName"]); Assert.Equal("The field Price must be between 20 and 100.", json["Price"]); - Assert.Equal("The Category field is required.", json["Category"]); - Assert.Equal("The field Contact Us must be a string with a maximum length of 20."+ - "The field Contact Us must match the regular expression '^[0-9]*$'.", json["Contact"]); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent("The Category field is required."), + json["Category"]); + AssertErrorEquals( + "The field Contact Us must be a string with a maximum length of 20." + + "The field Contact Us must match the regular expression " + + (TestPlatformHelper.IsMono ? "^[0-9]*$." : "'^[0-9]*$'."), + json["Contact"]); } [Fact] @@ -106,14 +114,33 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests var json = JsonConvert.DeserializeObject>(body); Assert.Equal("CompanyName cannot be null or empty.", json["[0].CompanyName"]); Assert.Equal("The field Price must be between 20 and 100.", json["[0].Price"]); - Assert.Equal("The Category field is required.", json["[0].Category"]); - Assert.Equal("The field Contact Us must be a string with a maximum length of 20." + - "The field Contact Us must match the regular expression '^[0-9]*$'.", json["[0].Contact"]); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal( + PlatformNormalizer.NormalizeContent("The Category field is required."), + json["[0].Category"]); + AssertErrorEquals( + "The field Contact Us must be a string with a maximum length of 20." + + "The field Contact Us must match the regular expression " + + (TestPlatformHelper.IsMono ? "^[0-9]*$." : "'^[0-9]*$'."), + json["[0].Contact"]); Assert.Equal("CompanyName cannot be null or empty.", json["[1].CompanyName"]); Assert.Equal("The field Price must be between 20 and 100.", json["[1].Price"]); - Assert.Equal("The Category field is required.", json["[1].Category"]); - Assert.Equal("The field Contact Us must be a string with a maximum length of 20." + - "The field Contact Us must match the regular expression '^[0-9]*$'.", json["[1].Contact"]); + Assert.Equal( + PlatformNormalizer.NormalizeContent("The Category field is required."), + json["[1].Category"]); + AssertErrorEquals( + "The field Contact Us must be a string with a maximum length of 20." + + "The field Contact Us must match the regular expression " + + (TestPlatformHelper.IsMono ? "^[0-9]*$." : "'^[0-9]*$'."), + json["[1].Contact"]); + } + + private void AssertErrorEquals(string expected, string actual) + { + // OrderBy is used because the order of the results may very depending on the platform / client. + Assert.Equal( + expected.Split('.').OrderBy(item => item, StringComparer.Ordinal), + actual.Split('.').OrderBy(item => item, StringComparer.Ordinal)); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/ViewEngineTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/ViewEngineTests.cs index 06469af086..5eeff1bd97 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/ViewEngineTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/ViewEngineTests.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Reflection; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing; using Microsoft.Framework.DependencyInjection; using Microsoft.Net.Http.Headers; using RazorWebSite; @@ -143,9 +144,13 @@ gb-partial"; fr-partial"; yield return new[] { "fr", expected2 }; - var expected3 = @"expander-index + if (!TestPlatformHelper.IsMono) + { + // https://github.com/aspnet/Mvc/issues/2759 + var expected3 = @"expander-index expander-partial"; - yield return new[] { "na", expected3 }; + yield return new[] { "!-invalid-!", expected3 }; + } } } @@ -288,7 +293,12 @@ View With Layout "; yield return new[] { "en-GB", expected1 }; - yield return new[] { "na", expected1 }; + + if (!TestPlatformHelper.IsMono) + { + // https://github.com/aspnet/Mvc/issues/2759 + yield return new[] { "!-invalid-!", expected1 }; + } var expected2 = @" @@ -443,7 +453,10 @@ Partial that does not specify Layout #if GENERATE_BASELINES ResourceFile.UpdateFile(_assembly, outputFile, expectedContent, responseContent); #else - Assert.Equal(expectedContent, responseContent, ignoreLineEndingDifferences: true); + Assert.Equal( + PlatformNormalizer.NormalizePath(expectedContent), + responseContent, + ignoreLineEndingDifferences: true); #endif } } diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/WebApiCompatShimBasicTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/WebApiCompatShimBasicTest.cs index 22aa9c8cb8..6a0deb7238 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/WebApiCompatShimBasicTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/WebApiCompatShimBasicTest.cs @@ -11,6 +11,8 @@ using System.Net.Http.Headers; using System.Threading.Tasks; using System.Web.Http; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Newtonsoft.Json; using Xunit; @@ -207,7 +209,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal("The field ID must be between 0 and 100.", json["ID"]); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/24 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ApiController_RequestProperty() { // Arrange @@ -229,7 +233,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(expected, content); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/24 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ApiController_RequestParameter() { // Arrange @@ -301,7 +307,12 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.NotNull(response.Content); - Assert.NotNull(response.Content.Headers.ContentLength); + if (!TestPlatformHelper.IsMono) + { + // Mono issue - https://github.com/aspnet/External/issues/20 + Assert.NotNull(response.Content.Headers.ContentLength); + } + Assert.Null(response.Headers.TransferEncodingChunked); // When HttpClient by default reads and buffers the resposne body, it diposes the diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlDataContractSerializerFormattersWrappingTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlDataContractSerializerFormattersWrappingTest.cs index 40ea6c5310..0864fd85b8 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlDataContractSerializerFormattersWrappingTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlDataContractSerializerFormattersWrappingTest.cs @@ -8,6 +8,7 @@ using System.Net.Http.Headers; using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc.Xml; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Xunit; @@ -19,7 +20,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests private readonly Action _app = new XmlFormattersWebSite.Startup().Configure; private readonly Action _configureServices = new XmlFormattersWebSite.Startup().ConfigureServices; - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("http://localhost/IEnumerable/ValueTypes")] [InlineData("http://localhost/IQueryable/ValueTypes")] public async Task CanWrite_ValueTypes(string url) @@ -42,7 +45,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests result); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("http://localhost/IEnumerable/NonWrappedTypes")] [InlineData("http://localhost/IQueryable/NonWrappedTypes")] public async Task CanWrite_NonWrappedTypes(string url) @@ -65,7 +70,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests result); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("http://localhost/IEnumerable/NonWrappedTypes_Empty")] [InlineData("http://localhost/IQueryable/NonWrappedTypes_Empty")] public async Task CanWrite_NonWrappedTypes_Empty(string url) @@ -87,7 +94,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests result); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("http://localhost/IEnumerable/NonWrappedTypes_NullInstance")] [InlineData("http://localhost/IQueryable/NonWrappedTypes_NullInstance")] public async Task CanWrite_NonWrappedTypes_NullInstance(string url) @@ -109,7 +118,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests result); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("http://localhost/IEnumerable/WrappedTypes")] [InlineData("http://localhost/IQueryable/WrappedTypes")] public async Task CanWrite_WrappedTypes(string url) @@ -133,7 +144,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests result); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("http://localhost/IEnumerable/WrappedTypes_Empty")] [InlineData("http://localhost/IQueryable/WrappedTypes_Empty")] public async Task CanWrite_WrappedTypes_Empty(string url) @@ -155,7 +168,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests result); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("http://localhost/IEnumerable/WrappedTypes_NullInstance")] [InlineData("http://localhost/IQueryable/WrappedTypes_NullInstance")] public async Task CanWrite_WrappedTypes_NullInstance(string url) @@ -177,7 +192,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests result); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task CanWrite_IEnumerableOf_SerializableErrors() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlDataContractSerializerInputFormatterTest.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlDataContractSerializerInputFormatterTest.cs index ffd50864fe..3cf2ada4ea 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlDataContractSerializerInputFormatterTest.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlDataContractSerializerInputFormatterTest.cs @@ -12,6 +12,7 @@ using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using XmlFormattersWebSite; using Xunit; @@ -32,7 +33,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests nameof(DataMemberAttribute.IsRequired), bool.TrueString); - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ThrowsOnInvalidInput_AndAddsToModelState() { // Arrange @@ -54,7 +57,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests data); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task RequiredDataIsProvided_AndModelIsBound_NoValidationErrors() { // Arrange @@ -83,7 +88,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests } // Verifies that the model state has errors related to body model validation. - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task DataMissingForRefereneceTypeProperties_AndModelIsBound_AndHasMixedValidationErrors() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlOutputFormatterTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlOutputFormatterTests.cs index a589266d78..80d4ac04af 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlOutputFormatterTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlOutputFormatterTests.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using FormatterWebSite; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc.Xml; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Xunit; @@ -20,7 +21,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests private readonly Action _app = new Startup().Configure; private readonly Action _configureServices = new Startup().ConfigureServices; - [Fact] + [ConditionalTheory] + // Mono.Xml2.XmlTextReader.ReadText is unable to read the XML. This is fixed in mono 4.3.0. + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task XmlDataContractSerializerOutputFormatterIsCalled() { // Arrange @@ -65,7 +68,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests await response.Content.ReadAsStringAsync()); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task XmlSerializerFailsAndDataContractSerializerIsCalled() { // Arrange @@ -111,7 +116,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests await response.Content.ReadAsStringAsync()); } - [Fact] + [ConditionalTheory] + // Mono.Xml2.XmlTextReader.ReadText is unable to read the XML. This is fixed in mono 4.3.0. + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task XmlDataContractSerializerOutputFormatter_WhenDerivedClassIsReturned() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlSerializerInputFormatterTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlSerializerInputFormatterTests.cs index d5ead5dd3c..ccef67406f 100644 --- a/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlSerializerInputFormatterTests.cs +++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/XmlSerializerInputFormatterTests.cs @@ -7,6 +7,7 @@ using System.Net.Http; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.DependencyInjection; using Xunit; @@ -38,7 +39,9 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests Assert.Equal(sampleInputInt.ToString(), await response.Content.ReadAsStringAsync()); } - [Fact] + [ConditionalTheory] + // Mono.Xml2.XmlTextReader.ReadText is unable to read the XML. This is fixed in mono 4.3.0. + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ThrowsOnInvalidInput_AndAddsToModelState() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.IntegrationTests/BodyValidationIntegrationTests.cs b/test/Microsoft.AspNet.Mvc.IntegrationTests/BodyValidationIntegrationTests.cs index 5555ce3e15..31838694c8 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/BodyValidationIntegrationTests.cs +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/BodyValidationIntegrationTests.cs @@ -6,6 +6,7 @@ using System.IO; using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.AspNet.Testing; using Xunit; namespace Microsoft.AspNet.Mvc.IntegrationTests @@ -60,7 +61,8 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests Assert.Equal("CustomParameter.Address", key); Assert.False(modelState.IsValid); var error = Assert.Single(modelState[key].Errors); - Assert.Equal("The Address field is required.", error.ErrorMessage); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal(PlatformNormalizer.NormalizeContent("The Address field is required."), error.ErrorMessage); } [Fact] @@ -209,7 +211,8 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests var street = Assert.Single(modelState, kvp => kvp.Key == "CustomParameter.Address.Street").Value; Assert.Equal(ModelValidationState.Invalid, street.ValidationState); var error = Assert.Single(street.Errors); - Assert.Equal("The Street field is required.", error.ErrorMessage); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal(PlatformNormalizer.NormalizeContent("The Street field is required."), error.ErrorMessage); } private class Person3 diff --git a/test/Microsoft.AspNet.Mvc.IntegrationTests/HeaderModelBinderIntegrationTest.cs b/test/Microsoft.AspNet.Mvc.IntegrationTests/HeaderModelBinderIntegrationTest.cs index dcaaa244bc..04dc1e36c2 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/HeaderModelBinderIntegrationTest.cs +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/HeaderModelBinderIntegrationTest.cs @@ -62,7 +62,8 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests var key = Assert.Single(modelState.Keys); Assert.Equal("CustomParameter.Address.Header", key); var error = Assert.Single(modelState[key].Errors); - Assert.Equal("The Street field is required.", error.ErrorMessage); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal(PlatformNormalizer.NormalizeContent("The Street field is required."), error.ErrorMessage); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.IntegrationTests/ValidationIntegrationTests.cs b/test/Microsoft.AspNet.Mvc.IntegrationTests/ValidationIntegrationTests.cs index e69c65cdda..013aeb8475 100644 --- a/test/Microsoft.AspNet.Mvc.IntegrationTests/ValidationIntegrationTests.cs +++ b/test/Microsoft.AspNet.Mvc.IntegrationTests/ValidationIntegrationTests.cs @@ -1095,7 +1095,9 @@ namespace Microsoft.AspNet.Mvc.IntegrationTests private static void AssertRequiredError(string key, ModelError error) { - Assert.Equal(string.Format("The {0} field is required.", key), error.ErrorMessage); + // Mono issue - https://github.com/aspnet/External/issues/19 + Assert.Equal(PlatformNormalizer.NormalizeContent( + string.Format("The {0} field is required.", key)), error.ErrorMessage); Assert.Null(error.Exception); } } diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/Directives/ChunkInheritanceUtilityTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/Directives/ChunkInheritanceUtilityTest.cs index dc53c8d209..87116f6ddf 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/Directives/ChunkInheritanceUtilityTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/Directives/ChunkInheritanceUtilityTest.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Razor.Chunks; +using Microsoft.AspNet.Testing; using Xunit; namespace Microsoft.AspNet.Mvc.Razor.Directives @@ -13,10 +14,10 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives { // Arrange var fileProvider = new TestFileProvider(); - fileProvider.AddFile(@"Views\accounts\_ViewImports.cshtml", "@using AccountModels"); - fileProvider.AddFile(@"Views\Shared\_ViewImports.cshtml", "@inject SharedHelper Shared"); - fileProvider.AddFile(@"Views\home\_ViewImports.cshtml", "@using MyNamespace"); - fileProvider.AddFile(@"Views\_ViewImports.cshtml", + fileProvider.AddFile(PlatformNormalizer.NormalizePath(@"Views\accounts\_ViewImports.cshtml"), "@using AccountModels"); + fileProvider.AddFile(PlatformNormalizer.NormalizePath(@"Views\Shared\_ViewImports.cshtml"), "@inject SharedHelper Shared"); + fileProvider.AddFile(PlatformNormalizer.NormalizePath(@"Views\home\_ViewImports.cshtml"), "@using MyNamespace"); + fileProvider.AddFile(PlatformNormalizer.NormalizePath(@"Views\_ViewImports.cshtml"), @"@inject MyHelper Helper @inherits MyBaseType @@ -35,13 +36,13 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives var utility = new ChunkInheritanceUtility(host, cache, defaultChunks); // Act - var chunkTrees = utility.GetInheritedChunkTrees(@"Views\home\Index.cshtml"); + var chunkTrees = utility.GetInheritedChunkTrees(PlatformNormalizer.NormalizePath(@"Views\home\Index.cshtml")); // Assert Assert.Collection(chunkTrees, chunkTree => { - var viewImportsPath = @"Views\home\_ViewImports.cshtml"; + var viewImportsPath = PlatformNormalizer.NormalizePath(@"Views\home\_ViewImports.cshtml"); Assert.Collection(chunkTree.Chunks, chunk => { @@ -62,7 +63,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives }, chunkTree => { - var viewImportsPath = @"Views\_ViewImports.cshtml"; + var viewImportsPath = PlatformNormalizer.NormalizePath(@"Views\_ViewImports.cshtml"); Assert.Collection(chunkTree.Chunks, chunk => { @@ -112,8 +113,8 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives // Arrange var fileProvider = new TestFileProvider(); fileProvider.AddFile(@"_ViewImports.cs", string.Empty); - fileProvider.AddFile(@"Views\_Layout.cshtml", string.Empty); - fileProvider.AddFile(@"Views\home\_not-viewimports.cshtml", string.Empty); + fileProvider.AddFile(PlatformNormalizer.NormalizePath(@"Views\_Layout.cshtml"), string.Empty); + fileProvider.AddFile(PlatformNormalizer.NormalizePath(@"Views\home\_not-viewimports.cshtml"), string.Empty); var cache = new DefaultChunkTreeCache(fileProvider); var host = new MvcRazorHost(cache); var defaultChunks = new Chunk[] @@ -124,7 +125,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives var utility = new ChunkInheritanceUtility(host, cache, defaultChunks); // Act - var chunkTrees = utility.GetInheritedChunkTrees(@"Views\home\Index.cshtml"); + var chunkTrees = utility.GetInheritedChunkTrees(PlatformNormalizer.NormalizePath(@"Views\home\Index.cshtml")); // Assert Assert.Empty(chunkTrees); @@ -135,7 +136,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives { // Arrange var fileProvider = new TestFileProvider(); - fileProvider.AddFile(@"Views\_ViewImports.cshtml", + fileProvider.AddFile(PlatformNormalizer.NormalizePath(@"Views\_ViewImports.cshtml"), "@inject DifferentHelper Html"); var cache = new DefaultChunkTreeCache(fileProvider); var host = new MvcRazorHost(cache); diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcCSharpRazorCodeParserTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcCSharpRazorCodeParserTest.cs index 1a3c5c03c9..1296ea07e5 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcCSharpRazorCodeParserTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcCSharpRazorCodeParserTest.cs @@ -78,7 +78,7 @@ namespace Microsoft.AspNet.Mvc.Razor .Accepts(AcceptedCharacters.None), factory.MetaCode("model ") .Accepts(AcceptedCharacters.None), - factory.Code(modelName + "\r\n") + factory.Code(modelName + Environment.NewLine) .As(new ModelChunkGenerator("RazorView", expectedModel)) .Accepts(AcceptedCharacters.AnyExceptNewline), factory.Markup("Bar") @@ -141,7 +141,7 @@ namespace Microsoft.AspNet.Mvc.Razor .Accepts(AcceptedCharacters.None), factory.MetaCode("model ") .Accepts(AcceptedCharacters.None), - factory.Code("Foo\r\n") + factory.Code("Foo" + Environment.NewLine) .As(new ModelChunkGenerator("RazorView", "Foo")) .Accepts(AcceptedCharacters.AnyExceptNewline), factory.EmptyHtml(), @@ -157,8 +157,10 @@ namespace Microsoft.AspNet.Mvc.Razor var expectedErrors = new[] { - new RazorError("Only one 'model' statement is allowed in a file.", - new SourceLocation(13, 1, 1), 5) + new RazorError( + "Only one 'model' statement is allowed in a file.", + PlatformNormalizer.NormalizedSourceLocation(13, 1, 1), + 5) }; // Act @@ -186,7 +188,7 @@ namespace Microsoft.AspNet.Mvc.Razor .Accepts(AcceptedCharacters.None), factory.MetaCode("model ") .Accepts(AcceptedCharacters.None), - factory.Code("Foo\r\n") + factory.Code("Foo" + Environment.NewLine) .As(new ModelChunkGenerator("RazorView", "Foo")) .Accepts(AcceptedCharacters.AnyExceptNewline), factory.EmptyHtml(), @@ -202,8 +204,10 @@ namespace Microsoft.AspNet.Mvc.Razor var expectedErrors = new[] { - new RazorError("The 'inherits' keyword is not allowed when a 'model' keyword is used.", - new SourceLocation(21, 1, 9), 1) + new RazorError( + "The 'inherits' keyword is not allowed when a 'model' keyword is used.", + PlatformNormalizer.NormalizedSourceLocation(21, 1, 9), + 1) }; // Act @@ -357,7 +361,7 @@ namespace Microsoft.AspNet.Mvc.Razor .Accepts(AcceptedCharacters.None), factory.MetaCode("inject ") .Accepts(AcceptedCharacters.None), - factory.Code(injectStatement + "\r\n") + factory.Code(injectStatement + Environment.NewLine) .As(new InjectParameterGenerator(expectedService, expectedPropertyName)) .Accepts(AcceptedCharacters.AnyExceptNewline), factory.Markup("Bar") @@ -377,7 +381,7 @@ namespace Microsoft.AspNet.Mvc.Razor { // Arrange var errors = new List(); - var documentContent = "@inject " + Environment.NewLine + "Bar"; + var documentContent = $"@inject {Environment.NewLine}Bar"; var factory = SpanFactory.CreateCsHtml(); var expectedSpans = new Span[] { @@ -386,7 +390,7 @@ namespace Microsoft.AspNet.Mvc.Razor .Accepts(AcceptedCharacters.None), factory.MetaCode("inject ") .Accepts(AcceptedCharacters.None), - factory.Code(" \r\n") + factory.Code(" " + Environment.NewLine) .As(new InjectParameterGenerator(string.Empty, string.Empty)) .Accepts(AcceptedCharacters.AnyExceptNewline), factory.Markup("Bar") @@ -444,7 +448,7 @@ namespace Microsoft.AspNet.Mvc.Razor { // Arrange var errors = new List(); - var documentContent = "@inject IMyService \r\nBar"; + var documentContent = $"@inject IMyService {Environment.NewLine}Bar"; var factory = SpanFactory.CreateCsHtml(); var expectedSpans = new Span[] { @@ -453,7 +457,7 @@ namespace Microsoft.AspNet.Mvc.Razor .Accepts(AcceptedCharacters.None), factory.MetaCode("inject ") .Accepts(AcceptedCharacters.None), - factory.Code(" IMyService \r\n") + factory.Code(" IMyService " + Environment.NewLine) .As(new InjectParameterGenerator("IMyService", string.Empty)) .Accepts(AcceptedCharacters.AnyExceptNewline), factory.Markup("Bar") diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs index 704c81e239..5b34fcf2a0 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/MvcRazorHostTest.cs @@ -19,6 +19,7 @@ using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.CodeGenerators; using Microsoft.AspNet.Razor.CodeGenerators.Visitors; using Microsoft.AspNet.Razor.Parser; +using Microsoft.AspNet.Testing; using Microsoft.Framework.Internal; using Xunit; @@ -28,11 +29,26 @@ namespace Microsoft.AspNet.Mvc.Razor { private static Assembly _assembly = typeof(MvcRazorHostTest).Assembly; + public static TheoryData NormalizeChunkInheritanceUtilityPaths_Data + { + get + { + var data = new TheoryData { "//" }; + + // The following scenarios are not relevant in Mono. + if (!TestPlatformHelper.IsMono) + { + data.Add("C:/"); + data.Add(@"\\"); + data.Add(@"C:\"); + } + + return data; + } + } + [Theory] - [InlineData("//")] - [InlineData("C:/")] - [InlineData(@"\\")] - [InlineData(@"C:\")] + [MemberData(nameof(NormalizeChunkInheritanceUtilityPaths_Data))] public void DecorateRazorParser_DesignTimeRazorPathNormalizer_NormalizesChunkInheritanceUtilityPaths( string rootPrefix) { @@ -57,10 +73,7 @@ namespace Microsoft.AspNet.Mvc.Razor } [Theory] - [InlineData("//")] - [InlineData("C:/")] - [InlineData(@"\\")] - [InlineData(@"C:\")] + [MemberData(nameof(NormalizeChunkInheritanceUtilityPaths_Data))] public void DecorateCodeGenerator_DesignTimeRazorPathNormalizer_NormalizesChunkInheritanceUtilityPaths( string rootPrefix) { @@ -108,7 +121,7 @@ namespace Microsoft.AspNet.Mvc.Razor { // Arrange var fileProvider = new TestFileProvider(); - var host = new MvcRazorHost(new DefaultChunkTreeCache(fileProvider)) + var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider)) { DesignTimeMode = true }; @@ -118,7 +131,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 7, documentLineIndex: 0, documentCharacterIndex: 7, - generatedAbsoluteIndex: 444, + generatedAbsoluteIndex: 432, generatedLineIndex: 12, generatedCharacterIndex: 7, contentLength: 8), @@ -126,7 +139,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 31, documentLineIndex: 2, documentCharacterIndex: 14, - generatedAbsoluteIndex: 823, + generatedAbsoluteIndex: 798, generatedLineIndex: 25, generatedCharacterIndex: 14, contentLength: 85), @@ -134,7 +147,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 135, documentLineIndex: 4, documentCharacterIndex: 17, - generatedAbsoluteIndex: 2313, + generatedAbsoluteIndex: 2258, generatedLineIndex: 55, generatedCharacterIndex: 95, contentLength: 3), @@ -142,7 +155,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 161, documentLineIndex: 5, documentCharacterIndex: 18, - generatedAbsoluteIndex: 2626, + generatedAbsoluteIndex: 2565, generatedLineIndex: 61, generatedCharacterIndex: 87, contentLength: 5), @@ -176,7 +189,7 @@ namespace Microsoft.AspNet.Mvc.Razor { // Arrange var fileProvider = new TestFileProvider(); - var host = new MvcRazorHost(new DefaultChunkTreeCache(fileProvider)) + var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider)) { DesignTimeMode = true }; @@ -187,7 +200,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 13, documentLineIndex: 0, documentCharacterIndex: 13, - generatedAbsoluteIndex: 1269, + generatedAbsoluteIndex: 1237, generatedLineIndex: 32, generatedCharacterIndex: 13, contentLength: 4), @@ -195,7 +208,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 41, documentLineIndex: 2, documentCharacterIndex: 5, - generatedAbsoluteIndex: 1353, + generatedAbsoluteIndex: 1316, generatedLineIndex: 37, generatedCharacterIndex: 6, contentLength: 21), @@ -210,7 +223,7 @@ namespace Microsoft.AspNet.Mvc.Razor { // Arrange var fileProvider = new TestFileProvider(); - var host = new MvcRazorHost(new DefaultChunkTreeCache(fileProvider)) + var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider)) { DesignTimeMode = true }; @@ -221,7 +234,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 1, documentLineIndex: 0, documentCharacterIndex: 1, - generatedAbsoluteIndex: 59, + generatedAbsoluteIndex: 56, generatedLineIndex: 3, generatedCharacterIndex: 0, contentLength: 17), @@ -229,7 +242,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 27, documentLineIndex: 1, documentCharacterIndex: 8, - generatedAbsoluteIndex: 706, + generatedAbsoluteIndex: 680, generatedLineIndex: 26, generatedCharacterIndex: 8, contentLength: 20), @@ -244,7 +257,7 @@ namespace Microsoft.AspNet.Mvc.Razor { // Arrange var fileProvider = new TestFileProvider(); - var host = new MvcRazorHost(new DefaultChunkTreeCache(fileProvider)) + var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider)) { DesignTimeMode = true }; @@ -255,7 +268,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 7, documentLineIndex: 0, documentCharacterIndex: 7, - generatedAbsoluteIndex: 214, + generatedAbsoluteIndex: 208, generatedLineIndex: 6, generatedCharacterIndex: 7, contentLength: 7), @@ -263,7 +276,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 23, documentLineIndex: 1, documentCharacterIndex: 8, - generatedAbsoluteIndex: 731, + generatedAbsoluteIndex: 705, generatedLineIndex: 26, generatedCharacterIndex: 8, contentLength: 20), @@ -271,7 +284,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 52, documentLineIndex: 2, documentCharacterIndex: 8, - generatedAbsoluteIndex: 957, + generatedAbsoluteIndex: 923, generatedLineIndex: 34, generatedCharacterIndex: 8, contentLength: 23), @@ -286,7 +299,7 @@ namespace Microsoft.AspNet.Mvc.Razor { // Arrange var fileProvider = new TestFileProvider(); - var host = new MvcRazorHost(new DefaultChunkTreeCache(fileProvider)) + var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider)) { DesignTimeMode = true }; @@ -297,7 +310,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 7, documentLineIndex: 0, documentCharacterIndex: 7, - generatedAbsoluteIndex: 222, + generatedAbsoluteIndex: 216, generatedLineIndex: 6, generatedCharacterIndex: 7, contentLength: 7), @@ -305,7 +318,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 23, documentLineIndex: 1, documentCharacterIndex: 8, - generatedAbsoluteIndex: 747, + generatedAbsoluteIndex: 721, generatedLineIndex: 26, generatedCharacterIndex: 8, contentLength: 20), @@ -313,7 +326,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 56, documentLineIndex: 2, documentCharacterIndex: 8, - generatedAbsoluteIndex: 977, + generatedAbsoluteIndex: 943, generatedLineIndex: 34, generatedCharacterIndex: 8, contentLength: 23), @@ -321,7 +334,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 90, documentLineIndex: 3, documentCharacterIndex: 8, - generatedAbsoluteIndex: 1210, + generatedAbsoluteIndex: 1168, generatedLineIndex: 42, generatedCharacterIndex: 8, contentLength: 21), @@ -329,7 +342,7 @@ namespace Microsoft.AspNet.Mvc.Razor documentAbsoluteIndex: 125, documentLineIndex: 4, documentCharacterIndex: 8, - generatedAbsoluteIndex: 1441, + generatedAbsoluteIndex: 1391, generatedLineIndex: 50, generatedCharacterIndex: 8, contentLength: 24), @@ -344,14 +357,14 @@ namespace Microsoft.AspNet.Mvc.Razor { // Arrange var fileProvider = new TestFileProvider(); - var host = new MvcRazorHost(new DefaultChunkTreeCache(fileProvider)) + var host = new MvcRazorHostWithNormalizedNewLine(new DefaultChunkTreeCache(fileProvider)) { DesignTimeMode = true }; host.NamespaceImports.Clear(); var expectedLineMappings = new[] { - BuildLineMapping(7, 0, 7, 194, 6, 7, 30), + BuildLineMapping(7, 0, 7, 188, 6, 7, 30), }; // Act and Assert @@ -481,6 +494,55 @@ namespace Microsoft.AspNet.Mvc.Razor } } + // Normalizes the newlines in different OS platforms. + private class MvcRazorHostWithNormalizedNewLine : MvcRazorHost + { + public MvcRazorHostWithNormalizedNewLine(IChunkTreeCache codeTreeCache) + : base(codeTreeCache) + { } + + public override CodeGenerator DecorateCodeGenerator( + CodeGenerator incomingBuilder, + CodeGeneratorContext context) + { + base.DecorateCodeGenerator(incomingBuilder, context); + + return new TestCSharpCodeGenerator( + context, + DefaultModel, + "Microsoft.AspNet.Mvc.Razor.Internal.RazorInjectAttribute", + new GeneratedTagHelperAttributeContext + { + ModelExpressionTypeName = ModelExpressionType, + CreateModelExpressionMethodName = CreateModelExpressionMethod + }); + } + + protected class TestCSharpCodeGenerator : MvcCSharpCodeGenerator + { + private readonly GeneratedTagHelperAttributeContext _tagHelperAttributeContext; + + public TestCSharpCodeGenerator(CodeGeneratorContext context, + string defaultModel, + string activateAttribute, + GeneratedTagHelperAttributeContext tagHelperAttributeContext) + : base(context, defaultModel, activateAttribute, tagHelperAttributeContext) + { + _tagHelperAttributeContext = tagHelperAttributeContext; + } + + protected override CSharpCodeWriter CreateCodeWriter() + { + // We normalize newlines so no matter what platform we're on + // they're consistent (for code generation tests). + var codeWriter = base.CreateCodeWriter(); + codeWriter.NewLine = "\n"; + + return codeWriter; + } + } + } + /// /// Used when testing Tag Helpers, it disables the unique ID generation feature. /// diff --git a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewHierarchyUtilityTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewHierarchyUtilityTest.cs index d82148d8c6..8b9da981fe 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewHierarchyUtilityTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Host.Test/ViewHierarchyUtilityTest.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.IO; +using Microsoft.AspNet.Testing; +using Microsoft.AspNet.Testing.xunit; using Xunit; namespace Microsoft.AspNet.Mvc.Razor @@ -41,8 +43,8 @@ namespace Microsoft.AspNet.Mvc.Razor // Arrange var expected = new[] { - @"Views\Home\_ViewStart.cshtml", - @"Views\_ViewStart.cshtml", + PlatformNormalizer.NormalizePath(@"Views\Home\_ViewStart.cshtml"), + PlatformNormalizer.NormalizePath(@"Views\_ViewStart.cshtml"), @"_ViewStart.cshtml" }; @@ -62,8 +64,8 @@ namespace Microsoft.AspNet.Mvc.Razor // Arrange var expected = new[] { - @"Views\Home\_ViewImports.cshtml", - @"Views\_ViewImports.cshtml", + PlatformNormalizer.NormalizePath(@"Views\Home\_ViewImports.cshtml"), + PlatformNormalizer.NormalizePath(@"Views\_ViewImports.cshtml"), @"_ViewImports.cshtml" }; @@ -83,7 +85,7 @@ namespace Microsoft.AspNet.Mvc.Razor // Arrange var expected = new[] { - @"Views\_ViewStart.cshtml", + PlatformNormalizer.NormalizePath(@"Views\_ViewStart.cshtml"), @"_ViewStart.cshtml" }; @@ -103,8 +105,8 @@ namespace Microsoft.AspNet.Mvc.Razor // Arrange var expected = new[] { - @"Views\Home\_ViewImports.cshtml", - @"Views\_ViewImports.cshtml", + PlatformNormalizer.NormalizePath(@"Views\Home\_ViewImports.cshtml"), + PlatformNormalizer.NormalizePath(@"Views\_ViewImports.cshtml"), @"_ViewImports.cshtml" }; @@ -124,7 +126,7 @@ namespace Microsoft.AspNet.Mvc.Razor // Arrange var expected = new[] { - @"Views\_ViewImports.cshtml", + PlatformNormalizer.NormalizePath(@"Views\_ViewImports.cshtml"), @"_ViewImports.cshtml" }; @@ -143,11 +145,11 @@ namespace Microsoft.AspNet.Mvc.Razor // Arrange var expected = new[] { - @"Areas\MyArea\Sub\Views\Admin\_ViewStart.cshtml", - @"Areas\MyArea\Sub\Views\_ViewStart.cshtml", - @"Areas\MyArea\Sub\_ViewStart.cshtml", - @"Areas\MyArea\_ViewStart.cshtml", - @"Areas\_ViewStart.cshtml", + PlatformNormalizer.NormalizePath(@"Areas\MyArea\Sub\Views\Admin\_ViewStart.cshtml"), + PlatformNormalizer.NormalizePath(@"Areas\MyArea\Sub\Views\_ViewStart.cshtml"), + PlatformNormalizer.NormalizePath(@"Areas\MyArea\Sub\_ViewStart.cshtml"), + PlatformNormalizer.NormalizePath(@"Areas\MyArea\_ViewStart.cshtml"), + PlatformNormalizer.NormalizePath(@"Areas\_ViewStart.cshtml"), @"_ViewStart.cshtml", }; var viewPath = Path.Combine("Areas", "MyArea", "Sub", "Views", "Admin", fileName); @@ -168,11 +170,11 @@ namespace Microsoft.AspNet.Mvc.Razor // Arrange var expected = new[] { - @"Areas\MyArea\Sub\Views\Admin\_ViewImports.cshtml", - @"Areas\MyArea\Sub\Views\_ViewImports.cshtml", - @"Areas\MyArea\Sub\_ViewImports.cshtml", - @"Areas\MyArea\_ViewImports.cshtml", - @"Areas\_ViewImports.cshtml", + PlatformNormalizer.NormalizePath(@"Areas\MyArea\Sub\Views\Admin\_ViewImports.cshtml"), + PlatformNormalizer.NormalizePath(@"Areas\MyArea\Sub\Views\_ViewImports.cshtml"), + PlatformNormalizer.NormalizePath(@"Areas\MyArea\Sub\_ViewImports.cshtml"), + PlatformNormalizer.NormalizePath(@"Areas\MyArea\_ViewImports.cshtml"), + PlatformNormalizer.NormalizePath(@"Areas\_ViewImports.cshtml"), @"_ViewImports.cshtml", }; var viewPath = Path.Combine("Areas", "MyArea", "Sub", "Views", "Admin", fileName); @@ -192,10 +194,10 @@ namespace Microsoft.AspNet.Mvc.Razor // Arrange var expected = new[] { - @"Areas\MyArea\Sub\Views\_ViewStart.cshtml", - @"Areas\MyArea\Sub\_ViewStart.cshtml", - @"Areas\MyArea\_ViewStart.cshtml", - @"Areas\_ViewStart.cshtml", + PlatformNormalizer.NormalizePath(@"Areas\MyArea\Sub\Views\_ViewStart.cshtml"), + PlatformNormalizer.NormalizePath(@"Areas\MyArea\Sub\_ViewStart.cshtml"), + PlatformNormalizer.NormalizePath(@"Areas\MyArea\_ViewStart.cshtml"), + PlatformNormalizer.NormalizePath(@"Areas\_ViewStart.cshtml"), @"_ViewStart.cshtml", }; var viewPath = Path.Combine("Areas", "MyArea", "Sub", "Views", "Admin", fileName); @@ -220,7 +222,9 @@ namespace Microsoft.AspNet.Mvc.Razor Assert.Empty(result); } - [Fact] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2745 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void GetViewStartLocations_ReturnsEmptySequence_IfPathIsRooted() { // Arrange @@ -233,7 +237,9 @@ namespace Microsoft.AspNet.Mvc.Razor Assert.Empty(result); } - [Fact] + [ConditionalTheory] + // https://github.com/aspnet/Mvc/issues/2745 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void GetViewImportsLocations_ReturnsEmptySequence_IfPathIsRooted() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/CompilerCacheTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/CompilerCacheTest.cs index 8ff44f34d2..f4247b1702 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/CompilerCacheTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/Compilation/CompilerCacheTest.cs @@ -11,6 +11,7 @@ using System.Text; using Microsoft.AspNet.FileProviders; using Microsoft.AspNet.Mvc.Razor.Internal; using Microsoft.AspNet.Mvc.Razor.Precompilation; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.Runtime; using Moq; using Xunit; @@ -348,7 +349,9 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation mockFileProvider.Verify(v => v.GetFileInfo(ViewPath), Times.Once()); } - [Fact] + [ConditionalTheory] + // Skipping for now since this is going to change. + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void GetOrAdd_IgnoresCachedValueIfFileIsIdentical_ButViewImportsWasAdedSinceTheCacheWasCreated() { // Arrange @@ -390,7 +393,9 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation Assert.Equal(expectedType, actual2.CompiledType); } - [Fact] + [ConditionalTheory] + // Skipping for now since this is going to change. + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void GetOrAdd_IgnoresCachedValueIfFileIsIdentical_ButGlobalWasDeletedSinceCacheWasCreated() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/LanguageViewLocationExpanderTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/LanguageViewLocationExpanderTest.cs index 42099969e6..807b54f6f9 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/LanguageViewLocationExpanderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/LanguageViewLocationExpanderTest.cs @@ -171,7 +171,7 @@ namespace Microsoft.AspNet.Mvc.Razor var viewLocationExpanderContext = new ViewLocationExpanderContext(new ActionContext(), "testView", false); var languageViewLocationExpander = new LanguageViewLocationExpander(); viewLocationExpanderContext.Values = new Dictionary(); - viewLocationExpanderContext.Values["language"] = "gb"; + viewLocationExpanderContext.Values["language"] = "!-invalid-culture-!"; // Act var expandedViewLocations = languageViewLocationExpander.ExpandViewLocations( diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/MvcRazorCodeParserTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/MvcRazorCodeParserTest.cs index d7ee5fa208..e7073c61d9 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/MvcRazorCodeParserTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/MvcRazorCodeParserTest.cs @@ -54,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Host.Test public void ParseModelKeyword_HandlesNullableTypes() { // Arrange + Act - var document = "@model Foo?\r\nBar"; + var document = $"@model Foo?{Environment.NewLine}Bar"; var spans = ParseDocument(document); // Assert @@ -66,7 +66,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Host.Test .Accepts(AcceptedCharacters.None), factory.MetaCode("model ") .Accepts(AcceptedCharacters.None), - factory.Code("Foo?\r\n") + factory.Code("Foo?" + Environment.NewLine) .As(new ModelChunkGenerator(DefaultBaseType, "Foo?")) .Accepts(AcceptedCharacters.AnyExceptNewline), factory.Markup("Bar") @@ -79,7 +79,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Host.Test public void ParseModelKeyword_HandlesArrays() { // Arrange + Act - var document = "@model Foo[[]][]\r\nBar"; + var document = $"@model Foo[[]][]{Environment.NewLine}Bar"; var spans = ParseDocument(document); // Assert @@ -91,7 +91,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Host.Test .Accepts(AcceptedCharacters.None), factory.MetaCode("model ") .Accepts(AcceptedCharacters.None), - factory.Code("Foo[[]][]\r\n") + factory.Code("Foo[[]][]" + Environment.NewLine) .As(new ModelChunkGenerator(DefaultBaseType, "Foo[[]][]")) .Accepts(AcceptedCharacters.AnyExceptNewline), factory.Markup("Bar") @@ -173,7 +173,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Host.Test .Accepts(AcceptedCharacters.None), factory.MetaCode("model ") .Accepts(AcceptedCharacters.None), - factory.Code("Foo\r\n") + factory.Code("Foo" + Environment.NewLine) .As(new ModelChunkGenerator(DefaultBaseType, "Foo")) .Accepts(AcceptedCharacters.AnyExceptNewline), factory.EmptyHtml(), @@ -189,7 +189,10 @@ namespace Microsoft.AspNet.Mvc.Razor.Host.Test var expectedErrors = new[] { - new RazorError("Only one 'model' statement is allowed in a file.", new SourceLocation(13, 1, 1), 5) + new RazorError( + "Only one 'model' statement is allowed in a file.", + PlatformNormalizer.NormalizedSourceLocation(13, 1, 1), + 5) }; expectedSpans.Zip(spans, (exp, span) => new { expected = exp, span = span }).ToList().ForEach(i => Assert.Equal(i.expected, i.span)); Assert.Equal(expectedSpans, spans.ToArray()); @@ -215,7 +218,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Host.Test .Accepts(AcceptedCharacters.None), factory.MetaCode("model ") .Accepts(AcceptedCharacters.None), - factory.Code("Foo\r\n") + factory.Code("Foo" + Environment.NewLine) .As(new ModelChunkGenerator(DefaultBaseType, "Foo")) .Accepts(AcceptedCharacters.AnyExceptNewline), factory.EmptyHtml(), @@ -231,7 +234,10 @@ namespace Microsoft.AspNet.Mvc.Razor.Host.Test var expectedErrors = new[] { - new RazorError("The 'inherits' keyword is not allowed when a 'model' keyword is used.", new SourceLocation(21, 1, 9), 1) + new RazorError( + "The 'inherits' keyword is not allowed when a 'model' keyword is used.", + PlatformNormalizer.NormalizedSourceLocation(21, 1, 9), + 1) }; expectedSpans.Zip(spans, (exp, span) => new { expected = exp, span = span }).ToList().ForEach(i => Assert.Equal(i.expected, i.span)); Assert.Equal(expectedSpans, spans.ToArray()); diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorFileHashTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorFileHashTest.cs index 3a50a74800..7006133fc3 100644 --- a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorFileHashTest.cs +++ b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorFileHashTest.cs @@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation new[] { "Hello world", "2346098258" }, new[] { "hello world", "222957957" }, new[] { "The quick brown fox jumped over the lazy dog", "2765681502" }, - new[] { longString, "1994223647" }, + new[] { longString, TestPlatformHelper.IsMono ? "4106555590" : "1994223647" }, new[] { stringWith4kChars.Substring(1), "2679155331" }, // 4095 chars new[] { stringWith4kChars, "2627329139" }, new[] { stringWith4kChars + "a", "556205849" }, // 4097 chars diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs index 3ce2b4fa25..950e0906ee 100644 --- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs +++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs @@ -12,6 +12,7 @@ using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.Rendering; +using Microsoft.AspNet.Testing.xunit; using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Routing; using Microsoft.Framework.Caching; @@ -80,7 +81,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers } } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void RendersImageTag_AddsFileVersion() { // Arrange @@ -152,7 +155,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers Assert.Equal("/images/test-image.png", srcAttribute.Value); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void RendersImageTag_AddsFileVersion_WithRequestPathBase() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/Internal/FileVersionProviderTest.cs b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/Internal/FileVersionProviderTest.cs index b75a679a50..85aa606f18 100644 --- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/Internal/FileVersionProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/Internal/FileVersionProviderTest.cs @@ -7,6 +7,7 @@ using System.Text; using Microsoft.AspNet.FileProviders; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.Caching; using Microsoft.Framework.Caching.Memory; using Moq; @@ -16,7 +17,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal { public class FileVersionProviderTest { - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("/hello/world", "/hello/world?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk")] [InlineData("/hello/world?q=test", "/hello/world?q=test&v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk")] [InlineData("/hello/world?q=foo&bar", "/hello/world?q=foo&bar&v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk")] @@ -37,7 +40,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal } // Verifies if the stream is closed after reading. - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void AddsVersionToFiles_DoesNotLockFileAfterReading() { // Arrange @@ -68,7 +73,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal Assert.Throws(() => fileVersionProvider.AddFileVersionToPath("/hello/world")); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("/testApp/hello/world", true, "/testApp")] [InlineData("/testApp/foo/bar/hello/world", true, "/testApp/foo/bar")] [InlineData("/test/testApp/hello/world", false, "/testApp")] @@ -91,7 +98,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal Assert.Equal(filePath + "?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", result); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void DoesNotAddVersion_IfFileNotFound() { // Arrange @@ -109,7 +118,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal Assert.Equal("http://contoso.com/hello/world", result); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void ReturnsValueFromCache() { // Arrange @@ -127,7 +138,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal Assert.Equal("FromCache", result); } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("/hello/world", "/hello/world", null)] [InlineData("/testApp/hello/world", "/hello/world", "/testApp")] public void SetsValueInCache(string filePath, string watchPath, string requestPathBase) diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/LinkTagHelperTest.cs b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/LinkTagHelperTest.cs index 1ca6ea4491..29406a39aa 100644 --- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/LinkTagHelperTest.cs +++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/LinkTagHelperTest.cs @@ -15,6 +15,7 @@ using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.TagHelpers.Internal; using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Routing; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.Caching; using Microsoft.Framework.Caching.Memory; using Microsoft.Framework.Logging; @@ -572,7 +573,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers output.Content.GetContent()); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void RendersLinkTags_AddsFileVersion() { // Arrange @@ -613,7 +616,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers output.Content.GetContent()); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void RendersLinkTags_AddsFileVersion_WithRequestPathBase() { // Arrange @@ -654,7 +659,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers output.Content.GetContent()); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void RendersLinkTags_GlobbedHref_AddsFileVersion() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ScriptTagHelperTest.cs b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ScriptTagHelperTest.cs index 74eeee8b07..34238c53be 100644 --- a/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ScriptTagHelperTest.cs +++ b/test/Microsoft.AspNet.Mvc.TagHelpers.Test/ScriptTagHelperTest.cs @@ -15,6 +15,7 @@ using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.TagHelpers.Internal; using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Routing; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.Caching; using Microsoft.Framework.Caching.Memory; using Microsoft.Framework.Logging; @@ -617,7 +618,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers "", output.Content.GetContent()); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task RenderScriptTags_WithFileVersion() { // Arrange @@ -654,7 +657,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers "", output.Content.GetContent()); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task RenderScriptTags_WithFileVersion_AndRequestPathBase() { // Arrange @@ -691,7 +696,9 @@ namespace Microsoft.AspNet.Mvc.TagHelpers "", output.Content.GetContent()); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task RenderScriptTags_FallbackSrc_WithFileVersion() { // Arrange @@ -729,12 +736,15 @@ namespace Microsoft.AspNet.Mvc.TagHelpers // Assert Assert.Equal( "\r\n{Environment.NewLine}" + + "", output.Content.GetContent()); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/21 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task RenderScriptTags_GlobbedSrc_WithFileVersion() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/PlatformNormalizer.cs b/test/Microsoft.AspNet.Mvc.TestCommon/PlatformNormalizer.cs new file mode 100644 index 0000000000..ca4decaf73 --- /dev/null +++ b/test/Microsoft.AspNet.Mvc.TestCommon/PlatformNormalizer.cs @@ -0,0 +1,67 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.RegularExpressions; +using Microsoft.AspNet.Testing; +using Microsoft.AspNet.Razor; + +namespace Microsoft.AspNet.Mvc +{ + public static class PlatformNormalizer + { + // Mono issue - https://github.com/aspnet/External/issues/19 + public static string NormalizeContent(string input) + { + if (TestPlatformHelper.IsMono) + { + var equivalents = new Dictionary { + { + "The [0-9a-zA-Z ]+ field is required.", "RequiredAttribute_ValidationError" + }, + { + "'[0-9a-zA-Z ]+' and '[0-9a-zA-Z ]+' do not match.", "CompareAttribute_MustMatch" + }, + { + "The field [0-9a-zA-Z ]+ must be a string with a minimum length of [0-9]+ and a " + + "maximum length of [0-9]+.", + "StringLengthAttribute_ValidationErrorIncludingMinimum" + }, + }; + + var result = input; + + foreach (var kvp in equivalents) + { + result = Regex.Replace(result, kvp.Key, kvp.Value); + } + + return result; + } + + return input; + } + + // Each new line character is returned as "_". + public static string GetNewLinesAsUnderscores(int numberOfNewLines) + { + return new string('_', numberOfNewLines * Environment.NewLine.Length); + } + + public static string NormalizePath(string path) + { + return path.Replace('\\', Path.DirectorySeparatorChar); + } + + // Assuming windows based source location is passed in, + // it gets normalized to other platforms. + public static SourceLocation NormalizedSourceLocation(int absoluteIndex, int lineIndex, int characterIndex) + { + var windowsNewLineLength = "\r\n".Length; + var differenceInLength = windowsNewLineLength - Environment.NewLine.Length; + return new SourceLocation(absoluteIndex - (differenceInLength * lineIndex), lineIndex, characterIndex); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/DefaultContentNegotiatorTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/DefaultContentNegotiatorTest.cs index 2dfef27bc3..960a49392d 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/DefaultContentNegotiatorTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/DefaultContentNegotiatorTest.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Net.Http.Formatting.Mocks; using System.Net.Http.Headers; using System.Text; +using Microsoft.AspNet.Testing; using Microsoft.TestCommon; using Newtonsoft.Json.Linq; using Xunit; @@ -392,7 +393,9 @@ namespace System.Net.Http.Formatting _request.Headers.Add("x-requested-with", "XMLHttpRequest"); // Act - var result = _negotiator.Negotiate(typeof(JToken), _request, new MediaTypeFormatterCollection()); + // Mono issue - https://github.com/aspnet/External/issues/27 + var type = TestPlatformHelper.IsMono ? typeof(string) : typeof(JToken); + var result = _negotiator.Negotiate(type, _request, new MediaTypeFormatterCollection()); Assert.Equal("application/json", result.MediaType.MediaType); Assert.IsType(result.Formatter); diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs index 3ad2773beb..1689860ec3 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpErrorTest.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Net.Http.Formatting; using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.AspNet.Testing.xunit; using Newtonsoft.Json.Linq; using Xunit; @@ -132,7 +133,9 @@ namespace System.Web.Http.Dispatcher Assert.Contains("c", data); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/25 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void HttpError_Roundtrips_WithXmlFormatter() { HttpError error = new HttpError("error") { { "ErrorCode", 42 }, { "Data", new[] { "a", "b", "c" } } }; diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageExtensionsTest.cs index 511f9f06d0..009b981be5 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageExtensionsTest.cs @@ -7,6 +7,7 @@ using System.Net.Http.Headers; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.WebApiCompatShim; +using Microsoft.AspNet.Testing; using Microsoft.Framework.OptionsModel; #if !DNXCORE50 using Moq; @@ -25,7 +26,10 @@ namespace System.Net.Http var ex = Assert.Throws( () => request.CreateResponse(HttpStatusCode.OK, CreateValue(), "foo/bar; param=value")); - Assert.Equal("The format of value 'foo/bar; param=value' is invalid.", ex.Message); + Assert.Equal( + TestPlatformHelper.IsMono ? + "Invalid format." : + "The format of value 'foo/bar; param=value' is invalid.", ex.Message); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageFeatureTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageFeatureTest.cs index d75c91a2c4..c0f167f9bc 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageFeatureTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpRequestMessage/HttpRequestMessageFeatureTest.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; +using Microsoft.AspNet.Testing.xunit; using Xunit; namespace Microsoft.AspNet.Mvc.WebApiCompatShim @@ -51,7 +52,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim Assert.Equal(new HttpMethod("OPTIONS"), request.Method); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/24 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void HttpRequestMessage_CopiesHeader() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs index 7267c2d643..eafd06a84a 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/HttpResponseMessageOutputFormatterTests.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; using Microsoft.AspNet.Mvc.WebApiCompatShim; +using Microsoft.AspNet.Testing.xunit; using Moq; using Moq.Protected; using Xunit; @@ -40,7 +41,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest streamContent.Protected().Verify("Dispose", Times.Once(), true); } - [Fact] + [ConditionalTheory] + // Issue - https://github.com/aspnet/External/issues/20 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ExplicitlySet_ChunkedEncodingFlag_IsIgnored() { // Arrange @@ -62,7 +65,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest Assert.NotNull(httpContext.Response.ContentLength); } - [Fact] + [ConditionalTheory] + // Issue - https://github.com/aspnet/External/issues/20 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ExplicitlySet_ChunkedEncodingHeader_IsIgnored() { // Arrange @@ -85,7 +90,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest Assert.NotNull(httpContext.Response.ContentLength); } - [Fact] + [ConditionalTheory] + // Issue - https://github.com/aspnet/External/issues/20 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ExplicitlySet_MultipleEncodings_ChunkedNotIgnored() { // Arrange @@ -110,7 +117,9 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShimTest Assert.NotNull(httpContext.Response.ContentLength); } - [Fact] + [ConditionalTheory] + // Issue - https://github.com/aspnet/External/issues/20 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ExplicitlySet_MultipleEncodingsUsingChunkedFlag_ChunkedNotIgnored() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.Xml.Test/EnumerableWrapperProviderTest.cs b/test/Microsoft.AspNet.Mvc.Xml.Test/EnumerableWrapperProviderTest.cs index b2921e1f0a..69b6e9aa65 100644 --- a/test/Microsoft.AspNet.Mvc.Xml.Test/EnumerableWrapperProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Xml.Test/EnumerableWrapperProviderTest.cs @@ -82,8 +82,9 @@ namespace Microsoft.AspNet.Mvc.Xml public void ThrowsArugmentExceptionFor_ConcreteEnumerableOfT(Type declaredType) { // Arrange - var expectedMessage = "The type must be an interface and must be or derive from 'IEnumerable`1'." + - "\r\nParameter name: sourceEnumerableOfT"; + var expectedMessage = + "The type must be an interface and must be or derive from 'IEnumerable`1'." + + $"{Environment.NewLine}Parameter name: sourceEnumerableOfT"; // Act and Assert var ex = Assert.Throws(() => new EnumerableWrapperProvider( diff --git a/test/Microsoft.AspNet.Mvc.Xml.Test/SerializableErrorWrapperProviderTest.cs b/test/Microsoft.AspNet.Mvc.Xml.Test/SerializableErrorWrapperProviderTest.cs index 74d0e8f28b..badcb801c5 100644 --- a/test/Microsoft.AspNet.Mvc.Xml.Test/SerializableErrorWrapperProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Xml.Test/SerializableErrorWrapperProviderTest.cs @@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.Xml var wrapperProvider = new SerializableErrorWrapperProvider(); var person = new Person() { Id = 10, Name = "John" }; var expectedMessage = string.Format("The object to be wrapped must be of type '{0}'" + - " but was of type 'Person'.\r\nParameter name: original", + $" but was of type 'Person'.{Environment.NewLine}Parameter name: original", typeof(SerializableErrorWrapper).Name); // Act and Assert diff --git a/test/Microsoft.AspNet.Mvc.Xml.Test/SerializableErrorWrapperTests.cs b/test/Microsoft.AspNet.Mvc.Xml.Test/SerializableErrorWrapperTests.cs index 4ccf79f406..9385b05679 100644 --- a/test/Microsoft.AspNet.Mvc.Xml.Test/SerializableErrorWrapperTests.cs +++ b/test/Microsoft.AspNet.Mvc.Xml.Test/SerializableErrorWrapperTests.cs @@ -8,6 +8,7 @@ using System.Text; using System.Xml; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.Xml; +using Microsoft.AspNet.Testing; using Xunit; namespace Microsoft.AspNet.Mvc @@ -92,8 +93,15 @@ namespace Microsoft.AspNet.Mvc var res = new StreamReader(outputStream, Encoding.UTF8).ReadToEnd(); // Assert - Assert.Equal("" + - "Test Error 1 Test Error 2Test Error 3", res); + var expectedContent = + TestPlatformHelper.IsMono ? + "Test Error 1 Test Error 2" + + "Test Error 3" : + "" + + "Test Error 1 Test Error 2Test Error 3"; + + Assert.Equal(expectedContent, res); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.Mvc.Xml.Test/XmlAssertTest.cs b/test/Microsoft.AspNet.Mvc.Xml.Test/XmlAssertTest.cs index 7cf74bf068..be1482fda0 100644 --- a/test/Microsoft.AspNet.Mvc.Xml.Test/XmlAssertTest.cs +++ b/test/Microsoft.AspNet.Mvc.Xml.Test/XmlAssertTest.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using Microsoft.AspNet.Testing; +using Microsoft.AspNet.Testing.xunit; using Xunit; using Xunit.Sdk; @@ -41,6 +43,14 @@ namespace Microsoft.AspNet.Mvc.Xml [InlineData("]]>", "]]>")] public void ReturnsSuccessfully_WithEmptyElements(string input1, string input2) { + // DeepEquals returns false even though the generated XML documents are equal. + // This is fixed in Mono 4.3.0 + if (TestPlatformHelper.IsMono + && input1 == "]]>") + { + return; + } + XmlAssert.Equal(input1, input2); } @@ -54,7 +64,10 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Throws(() => XmlAssert.Equal(input1, input2)); } - [Fact] + [ConditionalTheory] + // DeepEquals returns false even though the generated XML documents are equal. + // This is fixed in Mono 4.3.0 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void ReturnsSuccessfully_WithMatchingXmlDeclaration_IgnoringCase() { // Arrange diff --git a/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs b/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs index f07ddf6aa6..e85ecb8a6b 100644 --- a/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerInputFormatterTest.cs @@ -13,6 +13,7 @@ using System.Xml; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Testing; +using Microsoft.AspNet.Testing.xunit; using Moq; using Xunit; @@ -53,7 +54,9 @@ namespace Microsoft.AspNet.Mvc.Xml public TestLevelOne TestOne { get; set; } } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData("application/xml", true)] [InlineData("application/*", true)] [InlineData("*/*", true)] @@ -81,7 +84,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Equal(expectedCanRead, result); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void XmlDataContractSerializer_CachesSerializerForType() { // Arrange @@ -125,7 +130,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.True(formatter.SupportedEncodings.Any(i => i.WebName == "utf-16")); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_ReadsSimpleTypes() { // Arrange @@ -152,7 +159,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Equal(expectedString, levelOneModel.sampleString); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_ReadsComplexTypes() { // Arrange @@ -182,7 +191,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Equal(expectedString, levelTwoModel.TestOne.sampleString); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_ReadsWhenMaxDepthIsModified() { // Arrange @@ -206,7 +217,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Equal(expectedInt, dummyModel.SampleInt); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_ThrowsOnExceededMaxDepth() { if (TestPlatformHelper.IsMono) @@ -229,7 +242,9 @@ namespace Microsoft.AspNet.Mvc.Xml await Assert.ThrowsAsync(typeof(SerializationException), async () => await formatter.ReadAsync(context)); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_ThrowsWhenReaderQuotasAreChanged() { if (TestPlatformHelper.IsMono) @@ -262,7 +277,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Throws(typeof(ArgumentException), () => formatter.MaxDepth = 0); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_VerifyStreamIsOpenAfterRead() { // Arrange @@ -280,7 +297,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.True(context.HttpContext.Request.Body.CanRead); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_FallsbackToUTF8_WhenCharSet_NotInContentType() { // Arrange @@ -307,7 +326,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Equal(expectedMessage, ex.Message); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_UsesContentTypeCharSet_ToReadStream() { // Arrange @@ -331,7 +352,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Equal(expectedMessage, ex.Message); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_IgnoresBOMCharacters() { // Arrange @@ -362,7 +385,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Equal(expectedBytes, Encoding.UTF8.GetBytes(levelTwoModel.SampleString)); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_AcceptsUTF16Characters() { // Arrange @@ -393,7 +418,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Equal(expectedString, levelOneModel.sampleString); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_ThrowsWhenNotConfiguredWithRootName() { // Arrange @@ -412,7 +439,9 @@ namespace Microsoft.AspNet.Mvc.Xml await Assert.ThrowsAsync(typeof(SerializationException), async () => await formatter.ReadAsync(context)); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_ReadsWhenConfiguredWithRootName() { // Arrange @@ -448,7 +477,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Equal(expectedInt, dummyModel.SampleInt); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_ThrowsWhenNotConfiguredWithKnownTypes() { // Arrange @@ -468,7 +499,9 @@ namespace Microsoft.AspNet.Mvc.Xml await Assert.ThrowsAsync(typeof(SerializationException), async () => await formatter.ReadAsync(context)); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task ReadAsync_ReadsWhenConfiguredWithKnownTypes() { // Arrange @@ -504,6 +537,7 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Equal(expectedInt, dummyModel.SampleInt); Assert.Equal(expectedString, dummyModel.SampleString); } + private InputFormatterContext GetInputFormatterContext(byte[] contentBytes, Type modelType) { var httpContext = GetHttpContext(contentBytes); diff --git a/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs b/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs index 8aa3d8506f..51b901a6af 100644 --- a/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs +++ b/test/Microsoft.AspNet.Mvc.Xml.Test/XmlDataContractSerializerOutputFormatterTest.cs @@ -10,6 +10,8 @@ using System.Threading.Tasks; using System.Xml; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Internal; +using Microsoft.AspNet.Testing; +using Microsoft.AspNet.Testing.xunit; using Microsoft.Net.Http.Headers; using Moq; using Xunit; @@ -94,6 +96,13 @@ namespace Microsoft.AspNet.Mvc.Xml [MemberData(nameof(BasicTypeValues))] public async Task WriteAsync_CanWriteBasicTypes(object input, string expectedOutput) { + // ConditionalThoery seems to throw when used with Member data. Hence using if case here. + if (TestPlatformHelper.IsMono) + { + // Mono issue - https://github.com/aspnet/External/issues/18 + return; + } + // Arrange var formatter = new XmlDataContractSerializerOutputFormatter(); var outputFormatterContext = GetOutputFormatterContext(input, typeof(object)); @@ -109,7 +118,9 @@ namespace Microsoft.AspNet.Mvc.Xml XmlAssert.Equal(expectedOutput, content); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void XmlDataContractSerializer_CachesSerializerForType() { // Arrange @@ -125,7 +136,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.Equal(1, formatter.createSerializerCalledCount); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public void DefaultConstructor_ExpectedWriterSettings_Created() { // Arrange and Act @@ -139,7 +152,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.False(writerSettings.CheckCharacters); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task SuppliedWriterSettings_TakeAffect() { // Arrange @@ -165,7 +180,9 @@ namespace Microsoft.AspNet.Mvc.Xml XmlAssert.Equal(expectedOutput, content); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_WritesSimpleTypes() { // Arrange @@ -188,7 +205,9 @@ namespace Microsoft.AspNet.Mvc.Xml XmlAssert.Equal(expectedOutput, content); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_WritesComplexTypes() { // Arrange @@ -221,7 +240,9 @@ namespace Microsoft.AspNet.Mvc.Xml XmlAssert.Equal(expectedOutput, content); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_WritesOnModifiedWriterSettings() { // Arrange @@ -250,7 +271,9 @@ namespace Microsoft.AspNet.Mvc.Xml XmlAssert.Equal(expectedOutput, content); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_WritesUTF16Output() { // Arrange @@ -278,7 +301,9 @@ namespace Microsoft.AspNet.Mvc.Xml XmlAssert.Equal(expectedOutput, content); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_WritesIndentedOutput() { // Arrange @@ -302,7 +327,9 @@ namespace Microsoft.AspNet.Mvc.Xml XmlAssert.Equal(expectedOutput, content); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_VerifyBodyIsNotClosedAfterOutputIsWritten() { // Arrange @@ -318,7 +345,9 @@ namespace Microsoft.AspNet.Mvc.Xml Assert.True(body.CanRead); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_DoesntFlushOutputStream() { // Arrange @@ -353,6 +382,13 @@ namespace Microsoft.AspNet.Mvc.Xml [MemberData(nameof(TypesForCanWriteResult))] public void CanWriteResult_ReturnsExpectedOutput(object input, Type declaredType, bool expectedOutput) { + // ConditionalThoery seems to throw when used with Member data. Hence using if case here. + if (TestPlatformHelper.IsMono) + { + // Mono issue - https://github.com/aspnet/External/issues/18 + return; + } + // Arrange var formatter = new XmlDataContractSerializerOutputFormatter(); var outputFormatterContext = GetOutputFormatterContext(input, declaredType); @@ -377,7 +413,9 @@ namespace Microsoft.AspNet.Mvc.Xml } } - [Theory] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [MemberData(nameof(TypesForGetSupportedContentTypes))] public void GetSupportedContentTypes_ReturnsSupportedTypes(Type declaredType, Type runtimeType, object expectedOutput) @@ -400,7 +438,9 @@ namespace Microsoft.AspNet.Mvc.Xml } } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_ThrowsWhenNotConfiguredWithKnownTypes() { // Arrange @@ -413,7 +453,9 @@ namespace Microsoft.AspNet.Mvc.Xml async () => await formatter.WriteAsync(outputFormatterContext)); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_ThrowsWhenNotConfiguredWithPreserveReferences() { // Arrange @@ -429,7 +471,9 @@ namespace Microsoft.AspNet.Mvc.Xml async () => await formatter.WriteAsync(outputFormatterContext)); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_WritesWhenConfiguredWithRootName() { // Arrange @@ -470,7 +514,9 @@ namespace Microsoft.AspNet.Mvc.Xml XmlAssert.Equal(expectedOutput, content); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_WritesWhenConfiguredWithKnownTypes() { // Arrange @@ -514,7 +560,9 @@ namespace Microsoft.AspNet.Mvc.Xml XmlAssert.Equal(expectedOutput, content); } - [Fact] + [ConditionalTheory] + // Mono issue - https://github.com/aspnet/External/issues/18 + [FrameworkSkipCondition(RuntimeFrameworks.Mono)] public async Task WriteAsync_WritesWhenConfiguredWithPreserveReferences() { // Arrange diff --git a/test/WebSites/RazorWebSite/Controllers/DirectivesController.cs b/test/WebSites/RazorWebSite/Controllers/DirectivesController.cs index dd8b4a6291..16948a36e2 100644 --- a/test/WebSites/RazorWebSite/Controllers/DirectivesController.cs +++ b/test/WebSites/RazorWebSite/Controllers/DirectivesController.cs @@ -14,7 +14,7 @@ namespace RazorWebSite public ViewResult ViewInheritsBasePageFromViewImports() { - return View("/views/directives/scoped/ViewInheritsBasePageFromViewImports.cshtml", + return View("/Views/Directives/Scoped/ViewInheritsBasePageFromViewImports.cshtml", new Person { Name = "Person2" }); } }