Fixing tests in Mono.

- Disabling tests which have corresponding bugs in mono.
- Fixing a few tests which do not handle *nix file system.
- Updating Travis configuration to use mono's alpha bits.
- Introducing PlatformNormalizer to normalize content across multiple platforms.
This commit is contained in:
sornaks 2015-06-18 13:46:46 -07:00
parent 7606c81482
commit 68523a3550
76 changed files with 1054 additions and 363 deletions

View File

@ -1,6 +1,6 @@
language: csharp
sudo: false
mono:
- 3.12.0
- alpha
script:
- ./build.sh --quiet verify
- ./build.sh --quiet verify

View File

@ -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<string>(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<string>(new string[] { "GET", "POST" }, action.HttpMethods);
Assert.Equal(new [] { "GET", "POST" }, action.HttpMethods.OrderBy(key => key, StringComparer.Ordinal));
}
[Fact]

View File

@ -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()
{

View File

@ -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<string, Person> { { "Joe", new Person() } , { "Mark", new Person() } },
@ -275,10 +275,15 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
typeof(Uri),
new List<Type>() { typeof(Uri) }
};
yield return new object[] { new Dictionary<string, Uri> {
{ "values", new Uri("/api/values", UriKind.Relative) },
{ "hello", new Uri("/api/hello", UriKind.Relative) }
}, typeof(Dictionary<string, Uri>), new List<Type>() { typeof(Uri) } };
// https://github.com/aspnet/External/issues/23
if (!TestPlatformHelper.IsMono)
{
yield return new object[] { new Dictionary<string, Uri> {
{ "values", new Uri("/api/values", UriKind.Relative) },
{ "hello", new Uri("/api/hello", UriKind.Relative) }
}, typeof(Dictionary<string, Uri>), new List<Type>() { typeof(Uri) } };
}
}
}

View File

@ -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(),

View File

@ -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)]

View File

@ -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")]

View File

@ -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<string, string, bool>
var data = new TheoryData<string, string, bool>
{
{ "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;
}
}

View File

@ -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<byte> AbcdIndentedUTF8Bytes
{
get
{
var bytes = new List<byte>();
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());

View File

@ -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]

View File

@ -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]

View File

@ -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(
"<input class=\"HtmlEncode[[text-box single-line]]\" data-val=\"HtmlEncode[[true]]\" " +
"data-val-required=\"HtmlEncode[[The DateTimeOffset field is required.]]\" id=\"HtmlEncode[[FieldPrefix]]\" " +
"name=\"HtmlEncode[[FieldPrefix]]\" type=\"HtmlEncode[[" +
dataTypeName +
"]]\" value=\"HtmlEncode[[" + expected + "]]\" />";
"]]\" 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(
"<input class=\"HtmlEncode[[text-box single-line]]\" data-val=\"HtmlEncode[[true]]\" " +
"data-val-required=\"HtmlEncode[[The DateTimeOffset field is required.]]\" id=\"HtmlEncode[[FieldPrefix]]\" " +
"data-val-required=\"HtmlEncode[[The DateTimeOffset field is required.]]\" id=\"HtmlEncode[[FieldPrefix]]\" " +
"name=\"HtmlEncode[[FieldPrefix]]\" type=\"HtmlEncode[[" +
dataTypeName +
"]]\" value=\"HtmlEncode[[" + expected + "]]\" />";
"]]\" 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(
"<input class=\"HtmlEncode[[text-box single-line]]\" data-val=\"HtmlEncode[[true]]\" " +
"data-val-required=\"HtmlEncode[[The DateTimeOffset field is required.]]\" id=\"HtmlEncode[[FieldPrefix]]\" " +
"name=\"HtmlEncode[[FieldPrefix]]\" type=\"HtmlEncode[[" +
dataTypeName +
"]]\" value=\"HtmlEncode[[Formatted as 2000-01-02T03:04:05.0600000+00:00]]\" />";
"]]\" value=\"HtmlEncode[[Formatted as 2000-01-02T03:04:05.0600000+00:00]]\" />");
var offset = TimeSpan.FromHours(0);
var model = new DateTimeOffset(

View File

@ -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(
@"<input checked=""HtmlEncode[[checked]]"" data-val=""HtmlEncode[[true]]"" " +
@"data-val-required=""HtmlEncode[[The Boolean field is required.]]"" id=""HtmlEncode[[Property3]]"" " +
@"name=""HtmlEncode[[Property3]]"" type=""HtmlEncode[[checkbox]]"" " +
@"value=""HtmlEncode[[false]]"" /><input name=""HtmlEncode[[Property3]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"value=""HtmlEncode[[false]]"" /><input name=""HtmlEncode[[Property3]]"" type=""HtmlEncode[[hidden]]"" 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(
@"<input checked=""HtmlEncode[[checked]]"" data-val=""HtmlEncode[[true]]"" " +
@"data-val-required=""HtmlEncode[[The Boolean field is required.]]"" id=""HtmlEncode[[Property3]]"" " +
@"name=""HtmlEncode[[Property3]]"" type=""HtmlEncode[[checkbox]]"" " +
@"value=""HtmlEncode[[false]]"" /><input name=""HtmlEncode[[Property3]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"value=""HtmlEncode[[false]]"" /><input name=""HtmlEncode[[Property3]]"" type=""HtmlEncode[[hidden]]"" 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(
@"<input checked=""HtmlEncode[[checked]]"" data-val=""HtmlEncode[[true]]"" " +
@"data-val-required=""HtmlEncode[[The Boolean field is required.]]"" id=""HtmlEncode[[Property1]]"" " +
@"name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[checkbox]]"" " +
@"value=""HtmlEncode[[true]]"" /><input name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"value=""HtmlEncode[[true]]"" /><input name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />");
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(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Boolean field is required.]]"" " +
@"id=""HtmlEncode[[Property1]]"" name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" />" +
@"<input name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"<input name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />");
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 = @"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Name field is required.]]"" id=""HtmlEncode[[Name]]""" +
@" name=""HtmlEncode[[Name]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" />" +
@"<input name=""HtmlEncode[[Name]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
// Mono issue - https://github.com/aspnet/External/issues/19
var expected = PlatformNormalizer.NormalizeContent(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Name field is required.]]"" id=""HtmlEncode[[Name]]""" +
@" name=""HtmlEncode[[Name]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" />" +
@"<input name=""HtmlEncode[[Name]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />");
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(
@"<input checked=""HtmlEncode[[checked]]"" data-val=""HtmlEncode[[true]]"" " +
@"data-val-required=""HtmlEncode[[The Boolean field is required.]]"" id=""HtmlEncode[[Property1]]"" " +
@"name=""HtmlEncode[[Property1]]"" Property1-Property3=""HtmlEncode[[Property3ObjValue]]"" " +
@"type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" /><input " +
@"name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"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(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Boolean field is required.]]"" " +
@"id=""HtmlEncode[[MyPrefix]]"" name=""HtmlEncode[[MyPrefix]]"" Property3=""HtmlEncode[[Property3Value]]"" " +
@"type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" /><input name=""HtmlEncode[[MyPrefix]]"" type=""HtmlEncode[[hidden]]"" " +
@"value=""HtmlEncode[[false]]"" />";
@"value=""HtmlEncode[[false]]"" />");
var helper = DefaultTemplatesUtilities.GetHtmlHelper(model: false);
var attributes = new Dictionary<string, object> { { "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(
@"<input checked=""HtmlEncode[[checked]]"" data-val=""HtmlEncode[[true]]"" " +
@"data-val-required=""HtmlEncode[[The Boolean field is required.]]"" id=""HtmlEncode[[ComplexProperty_Property1]]"" " +
@"name=""HtmlEncode[[ComplexProperty." +
@"Property1]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" /><input name=""HtmlEncode[[ComplexProperty.Property1]]""" +
@" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@" 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(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property1 field is required.]]"" " +
@"id=""HtmlEncode[[Property1]]"" name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" />" +
@"<input name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"<input name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />");
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(
@"<input {0}data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property1 field is required.]]"" " +
@"id=""HtmlEncode[[Property1]]"" name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" />" +
@"<input name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"<input name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />");
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(
@"<input checked=""HtmlEncode[[checked]]"" data-val=""HtmlEncode[[true]]"" " +
@"data-val-required=""HtmlEncode[[The Property3 field is required.]]"" " +
@"id=""HtmlEncode[[Property3]]"" name=""HtmlEncode[[Property3]]"" type=""HtmlEncode[[checkbox]]"" " +
@"value=""HtmlEncode[[false]]"" /><input name=""HtmlEncode[[Property3]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"value=""HtmlEncode[[false]]"" /><input name=""HtmlEncode[[Property3]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />");
var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData());
// Act
@ -467,9 +479,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
public void CheckBoxForGeneratesUnobtrusiveValidationAttributes()
{
// Arrange
var expected = @"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Name field is required.]]"" id=""HtmlEncode[[Name]]""" +
@" name=""HtmlEncode[[Name]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" />" +
@"<input name=""HtmlEncode[[Name]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
// Mono issue - https://github.com/aspnet/External/issues/19
var expected = PlatformNormalizer.NormalizeContent(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Name field is required.]]"" id=""HtmlEncode[[Name]]""" +
@" name=""HtmlEncode[[Name]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" />" +
@"<input name=""HtmlEncode[[Name]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />");
var metadataProvider = TestModelMetadataProvider.CreateDefaultProvider();
var viewDataDictionary = new ViewDataDictionary<ModelWithValidation>(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(
@"<input {0}data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property1 field is required.]]"" " +
@"id=""HtmlEncode[[Property1]]"" name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" />" +
@"<input name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"<input name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />");
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(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property1 field is required.]]"" " +
@"id=""HtmlEncode[[Property1]]"" name=""HtmlEncode[[Property1]]"" " +
@"Property1-Property3=""HtmlEncode[[Property3ObjValue]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" /><input " +
@"name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"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(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property1 field is required.]]"" " +
@"id=""HtmlEncode[[Property1]]"" name=""HtmlEncode[[Property1]]"" " +
@"Property3=""HtmlEncode[[Property3Value]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" /><input " +
@"name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"name=""HtmlEncode[[Property1]]"" type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />");
var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData());
var attributes = new Dictionary<string, object> { { "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(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property1 field is required.]]"" " +
@"id=""HtmlEncode[[MyPrefix_Property1]]"" name=""HtmlEncode[[MyPrefix.Property1]]"" Property3=""HtmlEncode[[PropValue]]"" " +
@"type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" /><input name=""HtmlEncode[[MyPrefix.Property1]]"" type=""HtmlEncode[[hidden]]"" " +
@"value=""HtmlEncode[[false]]"" />";
@"value=""HtmlEncode[[false]]"" />");
var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetTestModelViewData());
helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix";
var attributes = new Dictionary<string, object> { { "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(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property1 field is required.]]"" " +
@"id=""HtmlEncode[[ComplexProperty_Property1]]"" name=""HtmlEncode[[ComplexProperty." +
@"Property1]]"" type=""HtmlEncode[[checkbox]]"" value=""HtmlEncode[[true]]"" /><input name=""HtmlEncode[[ComplexProperty.Property1]]"" " +
@"type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />";
@"type=""HtmlEncode[[hidden]]"" value=""HtmlEncode[[false]]"" />");
var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetModelWithValidationViewData());
// Act

View File

@ -433,8 +433,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
public void HiddenGeneratesUnobtrusiveValidation()
{
// Arrange
var expected = @"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property2 field is required.]]"" " +
@"id=""HtmlEncode[[Property2]]"" name=""HtmlEncode[[Property2]]"" type=""HtmlEncode[[hidden]]"" value="""" />";
// Mono issue - https://github.com/aspnet/External/issues/19
var expected = PlatformNormalizer.NormalizeContent(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property2 field is required.]]"" " +
@"id=""HtmlEncode[[Property2]]"" name=""HtmlEncode[[Property2]]"" type=""HtmlEncode[[hidden]]"" value="""" />");
var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetViewDataWithModelStateAndModelAndViewDataValues());
// Act
@ -686,8 +688,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
public void HiddenFor_GeneratesUnobtrusiveValidationAttributes()
{
// Arrange
var expected = @"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property2 field is required.]]"" " +
@"id=""HtmlEncode[[Property2]]"" name=""HtmlEncode[[Property2]]"" type=""HtmlEncode[[hidden]]"" value="""" />";
// Mono issue - https://github.com/aspnet/External/issues/19
var expected = PlatformNormalizer.NormalizeContent(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property2 field is required.]]"" " +
@"id=""HtmlEncode[[Property2]]"" name=""HtmlEncode[[Property2]]"" type=""HtmlEncode[[hidden]]"" value="""" />");
var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetViewDataWithErrors());
// Act

View File

@ -160,8 +160,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
public void PasswordGeneratesUnobtrusiveValidation()
{
// Arrange
var expected = @"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property2 field is required.]]"" " +
@"id=""HtmlEncode[[Property2]]"" name=""HtmlEncode[[Property2]]"" type=""HtmlEncode[[password]]"" />";
// Mono issue - https://github.com/aspnet/External/issues/19
var expected = PlatformNormalizer.NormalizeContent(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property2 field is required.]]"" " +
@"id=""HtmlEncode[[Property2]]"" name=""HtmlEncode[[Property2]]"" type=""HtmlEncode[[password]]"" />");
var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetViewDataWithModelStateAndModelAndViewDataValues());
// Act
@ -266,8 +268,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
public void PasswordFor_GeneratesUnobtrusiveValidationAttributes()
{
// Arrange
var expected = @"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property2 field is required.]]"" " +
@"id=""HtmlEncode[[Property2]]"" name=""HtmlEncode[[Property2]]"" type=""HtmlEncode[[password]]"" />";
// Mono issue - https://github.com/aspnet/External/issues/19
var expected = PlatformNormalizer.NormalizeContent(
@"<input data-val=""HtmlEncode[[true]]"" data-val-required=""HtmlEncode[[The Property2 field is required.]]"" " +
@"id=""HtmlEncode[[Property2]]"" name=""HtmlEncode[[Property2]]"" type=""HtmlEncode[[password]]"" />");
var helper = DefaultTemplatesUtilities.GetHtmlHelper(GetViewDataWithErrors());
// Act

View File

@ -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)

View File

@ -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]

View File

@ -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(

View File

@ -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

View File

@ -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

View File

@ -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);
}
}

View File

@ -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<IApplicationBuilder> _app = new FilesWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _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

View File

@ -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

View File

@ -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
}

View File

@ -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);
}
}
}

View File

@ -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]

View File

@ -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<IServiceCollection> _configureServices = new FormatterWebSite.Startup().ConfigureServices;
[Fact]
[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/18
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
public async Task CheckIfXmlInputFormatterIsBeingCalled()
{
// Arrange

View File

@ -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());
}

View File

@ -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

View File

@ -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]

View File

@ -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
</fr-language-layout>";
yield return new[] { "fr", expected2 };
var expected3 =
if (!TestPlatformHelper.IsMono)
{
// https://github.com/aspnet/Mvc/issues/2759
var expected3 =
@"<language-layout>
index
partial
mypartial
</language-layout>";
yield return new[] { "na", expected3 };
yield return new[] { "!-invalid-!", expected3 };
}
}
}

View File

@ -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<Dictionary<string, string>>(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<Dictionary<string, string>>(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<IDictionary<string, IEnumerable<string>>>(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(
"<span class=\"field-validation-error\" data-valmsg-for=\"Vehicle.Year\"" +
" data-valmsg-replace=\"true\">The field Year must be between 1980 and 2034.</span>",
"<span class=\"field-validation-error\" data-valmsg-for=\"Vehicle.Year\"" +
" data-valmsg-replace=\"true\">Year is invalid</span>");
}
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
}

View File

@ -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<Dictionary<string, string>>(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]

View File

@ -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

View File

@ -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<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _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

View File

@ -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
}

View File

@ -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)

View File

@ -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<string> 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<string> 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<InvalidOperationException>(() => 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));
}
}
}

View File

@ -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<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _configureServices = new XmlFormattersWebSite.Startup().ConfigureServices;
public static TheoryData AcceptHeadersData
{
get
{
var data = new TheoryData<string>
{
"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)

View File

@ -156,7 +156,11 @@ page:<root>root-content</root>"
#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>root-content</root>"
#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
}
}

View File

@ -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

View File

@ -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<Dictionary<string, string>>(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));
}
}
}

View File

@ -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
</language-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 =
@"<fr-language-layout>
@ -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
}
}

View File

@ -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

View File

@ -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<IApplicationBuilder> _app = new XmlFormattersWebSite.Startup().Configure;
private readonly Action<IServiceCollection> _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

View File

@ -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

View File

@ -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<IApplicationBuilder> _app = new Startup().Configure;
private readonly Action<IServiceCollection> _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

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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);
}
}

View File

@ -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<TModel> 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<TModel> Html");
var cache = new DefaultChunkTreeCache(fileProvider);
var host = new MvcRazorHost(cache);

View File

@ -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<RazorError>();
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<RazorError>();
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")

View File

@ -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<string> { "//" };
// 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;
}
}
}
/// <summary>
/// Used when testing Tag Helpers, it disables the unique ID generation feature.
/// </summary>

View File

@ -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

View File

@ -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

View File

@ -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<string, string>();
viewLocationExpanderContext.Values["language"] = "gb";
viewLocationExpanderContext.Values["language"] = "!-invalid-culture-!";
// Act
var expandedViewLocations = languageViewLocationExpander.ExpandViewLocations(

View File

@ -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());

View File

@ -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

View File

@ -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

View File

@ -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<ObjectDisposedException>(() => 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)

View File

@ -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

View File

@ -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
"<script src=\"HtmlEncode[[/common.js]]\"></script>", 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
"</script>", 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
"</script>", 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(
"<script src=\"HtmlEncode[[/js/site.js?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk]]\">" +
"</script>\r\n<script>(isavailable()||document.write(\"<script src=\\\"JavaScriptStringEncode[[fallback.js" +
$"</script>{Environment.NewLine}" +
"<script>(isavailable()||document.write(\"<script src=\\\"JavaScriptStringEncode[[fallback.js" +
"?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk]]\\\"><\\/script>\"));</script>",
output.Content.GetContent());
}
[Fact]
[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
public async Task RenderScriptTags_GlobbedSrc_WithFileVersion()
{
// Arrange

View File

@ -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<string, string> {
{
"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);
}
}
}

View File

@ -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<JsonMediaTypeFormatter>(result.Formatter);

View File

@ -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" } } };

View File

@ -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<FormatException>(
() => 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]

View File

@ -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

View File

@ -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

View File

@ -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<ArgumentException>(() => new EnumerableWrapperProvider(

View File

@ -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

View File

@ -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("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<Error><key1>Test Error 1 Test Error 2</key1><key2>Test Error 3</key2></Error>", res);
var expectedContent =
TestPlatformHelper.IsMono ?
"<?xml version=\"1.0\" encoding=\"utf-8\"?><Error xmlns:i=\"" +
"http://www.w3.org/2001/XMLSchema-instance\"><key1>Test Error 1 Test Error 2</key1>" +
"<key2>Test Error 3</key2></Error>" :
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<Error><key1>Test Error 1 Test Error 2</key1><key2>Test Error 3</key2></Error>";
Assert.Equal(expectedContent, res);
}
}
}

View File

@ -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("<A><![CDATA[<greeting></greeting>]]></A>", "<A><![CDATA[<greeting></greeting>]]></A>")]
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 == "<A><![CDATA[<greeting></greeting>]]></A>")
{
return;
}
XmlAssert.Equal(input1, input2);
}
@ -54,7 +64,10 @@ namespace Microsoft.AspNet.Mvc.Xml
Assert.Throws<EqualException>(() => 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

View File

@ -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);

View File

@ -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

View File

@ -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" });
}
}