Allow ViewFeature tests to run in dnxcore50

This commit is contained in:
Pranav K 2015-10-05 18:23:31 -07:00
parent a0764faa86
commit a602d548e2
40 changed files with 125 additions and 53 deletions

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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.IO;
@ -8,7 +9,6 @@ using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.Abstractions;
@ -19,9 +19,7 @@ using Microsoft.AspNet.Mvc.ModelBinding.Validation;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Microsoft.AspNet.Routing;
using Microsoft.AspNet.Testing;
#if DNX451
using Moq;
#endif
using Newtonsoft.Json;
using Xunit;
@ -1833,3 +1831,5 @@ namespace Microsoft.AspNet.Mvc.Test
}
}
}
#endif

View File

@ -9,7 +9,9 @@ using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.Abstractions;
using Microsoft.AspNet.Routing;
#if MOCK_SUPPORT
using Moq;
#endif
using Newtonsoft.Json;
using Xunit;
@ -142,6 +144,7 @@ namespace Microsoft.AspNet.Mvc
}
}
#if MOCK_SUPPORT
[Fact]
public void ControllerFileStream_InvokedInUnitTests()
{
@ -178,6 +181,7 @@ namespace Microsoft.AspNet.Mvc
}
}
}
#endif
[Fact]
public void ControllerJson_InvokedInUnitTests()
@ -511,15 +515,15 @@ namespace Microsoft.AspNet.Mvc
public void ActionContextSetters_CanBeUsedWithControllerActionContext()
{
// Arrange
var actionDescriptor = new Mock<ActionDescriptor>();
var httpContext = new Mock<HttpContext>();
var routeData = new Mock<RouteData>();
var actionDescriptor = new ActionDescriptor();
var httpContext = new DefaultHttpContext();
var routeData = new RouteData();
var actionContext = new ActionContext()
{
ActionDescriptor = actionDescriptor.Object,
HttpContext = httpContext.Object,
RouteData = routeData.Object,
ActionDescriptor = actionDescriptor,
HttpContext = httpContext,
RouteData = routeData,
};
var controller = new TestabilityController();
@ -528,10 +532,10 @@ namespace Microsoft.AspNet.Mvc
controller.ActionContext = actionContext;
// Assert
Assert.Equal(httpContext.Object, controller.HttpContext);
Assert.Equal(routeData.Object, controller.RouteData);
Assert.Same(httpContext, controller.HttpContext);
Assert.Same(routeData, controller.RouteData);
Assert.Equal(actionContext.ModelState, controller.ModelState);
Assert.Equal(actionDescriptor.Object, actionContext.ActionDescriptor);
Assert.Same(actionDescriptor, actionContext.ActionDescriptor);
}
[Fact]

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.Linq;
using System.Reflection;
using Microsoft.Extensions.Internal;
using Xunit;
@ -14,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
{
// Arrange
var anonymous = new { bar_baz = "foo" };
var property = anonymous.GetType().GetProperties().First();
var property = anonymous.GetType().GetTypeInfo().DeclaredProperties.First();
// Act
var helper = new HtmlAttributePropertyHelper(property);
@ -29,7 +30,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
{
// Arrange
var anonymous = new { foo = "bar" };
var property = anonymous.GetType().GetProperties().First();
var property = anonymous.GetType().GetTypeInfo().DeclaredProperties.First();
// Act
var helper = new HtmlAttributePropertyHelper(property);
@ -44,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
{
// Arrange
var anonymous = new { bar = "baz" };
var property = anonymous.GetType().GetProperties().First();
var property = anonymous.GetType().GetTypeInfo().DeclaredProperties.First();
// Act
var helper = new HtmlAttributePropertyHelper(property);
@ -59,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures.Internal
{
// Arrange
var anonymous = new { foo = 32 };
var property = anonymous.GetType().GetProperties().First();
var property = anonymous.GetType().GetTypeInfo().DeclaredProperties.First();
// Act
var helper = new HtmlAttributePropertyHelper(property);

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.
#if MOCK_SUPPORT
using System;
using System.Diagnostics.Tracing;
using System.Threading.Tasks;
@ -119,4 +120,5 @@ namespace Microsoft.AspNet.Mvc
return httpContext;
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http.Internal;
@ -668,3 +669,4 @@ namespace Microsoft.AspNet.Mvc
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -339,4 +340,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
return Mock.Of<IUrlHelper>();
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -663,4 +664,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
public TestModel ComplexProperty { get; set; }
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using Microsoft.AspNet.Mvc.ModelBinding;
@ -227,4 +228,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
public InnerClass Inner { get; set; }
}
}
}
}
#endif

View File

@ -1,7 +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.Globalization;
#if MOCK_SUPPORT
using Microsoft.AspNet.Mvc.ModelBinding;
using Xunit;
@ -317,4 +317,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNet.Mvc.ViewFeatures;
@ -803,4 +804,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
htmlGenerator.Verify();
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -325,4 +326,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
dictionary.Select(keyValue => string.Format(" {0}=\"HtmlEncode[[{1}]]\"", keyValue.Key, keyValue.Value)));
}
}
}
}
#endif

View File

@ -1,10 +1,10 @@
// 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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq.Expressions;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.TestCommon;
@ -901,4 +901,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
public List<string> Property6 { get; } = new List<string>();
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Rendering;
@ -262,4 +263,5 @@ namespace Microsoft.AspNet.Mvc.Core
public InnerClass Inner { get; set; }
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.Mvc.Routing;
@ -161,4 +162,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
return string.Join(string.Empty, dict.Select(kvp => string.Format(" {0}=\"HtmlEncode[[{1}]]\"", kvp.Key, kvp.Value.ToString())));
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
@ -351,4 +352,5 @@ namespace Microsoft.AspNet.Mvc.Core
public InnerClass Inner { get; set; }
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Threading.Tasks;
using Microsoft.AspNet.Html.Abstractions;
@ -195,4 +196,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
}
}
#endif

View File

@ -1,10 +1,10 @@
// 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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq.Expressions;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.TestCommon;
@ -399,4 +399,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
public List<string> Property6 { get; } = new List<string>();
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -1709,4 +1710,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
public List<string> Property1 { get; } = new List<string>();
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System.Collections.Generic;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Xunit;
@ -296,3 +297,4 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -403,4 +404,5 @@ namespace Microsoft.AspNet.Mvc.Rendering
public string OrderedProperty1 { get; set; }
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Rendering;
@ -260,4 +261,5 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
return helper;
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System.IO;
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.Abstractions;
@ -43,3 +44,4 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System.IO;
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.Abstractions;
@ -76,4 +77,5 @@ namespace Microsoft.AspNet.Mvc
return viewComponentContext;
}
}
}
}
#endif

View File

@ -81,7 +81,10 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
GetAssemblyProvider()
.CandidateAssemblies
.SelectMany(a => a.DefinedTypes)
.Select(t => t.GetTypeInfo());
#if DNX451
.Select(t => t.GetTypeInfo())
#endif
;
}
private static IAssemblyProvider GetAssemblyProvider()

View File

@ -198,7 +198,10 @@ namespace Microsoft.AspNet.Mvc.ViewComponents
GetAssemblyProvider()
.CandidateAssemblies
.SelectMany(a => a.DefinedTypes)
.Select(t => t.GetTypeInfo());
#if DNX451
.Select(t => t.GetTypeInfo())
#endif
;
}
private static IAssemblyProvider GetAssemblyProvider()

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.
#if MOCK_SUPPORT
using System;
using System.IO;
using System.Text;
@ -96,4 +97,5 @@ namespace Microsoft.AspNet.Mvc
return httpContext;
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.IO;
using System.Threading.Tasks;
@ -369,4 +370,5 @@ namespace Microsoft.AspNet.Mvc
return viewComponentContext;
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Linq;
using Microsoft.AspNet.Http;
@ -299,4 +300,5 @@ namespace Microsoft.AspNet.Mvc.ViewEngines
{
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -390,4 +391,5 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
public string OrderedProperty1 { get; set; }
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -1164,4 +1165,5 @@ Environment.NewLine;
}
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Collections.Generic;
using System.IO;
@ -10,7 +11,6 @@ using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.Abstractions;
using Microsoft.AspNet.Mvc.ModelBinding;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Mvc.Routing;
using Microsoft.AspNet.Mvc.ViewEngines;
using Microsoft.AspNet.Routing;
using Microsoft.Extensions.OptionsModel;
@ -712,4 +712,5 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
public List<string> Collection { get; } = new List<string>();
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System.Diagnostics.Tracing;
using System.Threading.Tasks;
using Microsoft.AspNet.Http.Internal;
@ -225,3 +226,4 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
}
}
}
#endif

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.
#if MOCK_SUPPORT
using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc.Abstractions;
using Microsoft.AspNet.Mvc.Filters;
@ -78,3 +79,4 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
}
}
}
#endif

View File

@ -8,7 +8,6 @@ using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Features;
using Microsoft.AspNet.Http.Internal;
using Moq;
using Xunit;
namespace Microsoft.AspNet.Mvc.ViewFeatures

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Internal;
using Moq;
using Xunit;
namespace Microsoft.AspNet.Mvc.ViewFeatures

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.
#if MOCK_SUPPORT
using System;
using System.Collections;
using System.Collections.Generic;
@ -817,4 +818,5 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
public string Model { get; set; }
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Diagnostics.Tracing;
using System.IO;
@ -291,4 +292,5 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
listener);
}
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System.Diagnostics.Tracing;
using System.Threading.Tasks;
using Microsoft.AspNet.Http.Internal;
@ -225,3 +226,4 @@ namespace Microsoft.AspNet.Mvc.ViewFeatures
}
}
}
#endif

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.
#if MOCK_SUPPORT
using System;
using System.Diagnostics.Tracing;
using System.Threading.Tasks;
@ -119,4 +120,5 @@ namespace Microsoft.AspNet.Mvc
return httpContext;
}
}
}
}
#endif

View File

@ -19,7 +19,6 @@
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
"Microsoft.Extensions.TelemetryAdapter": "1.0.0-*",
"Microsoft.Extensions.WebEncoders.Testing": "1.0.0-*",
"Moq": "4.2.1312.1622",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"commands": {
@ -27,7 +26,11 @@
},
"frameworks": {
"dnx451": {
"compilationOptions": { "define": [ "MOCK_SUPPORT" ] }
}
"compilationOptions": { "define": [ "MOCK_SUPPORT" ] },
"dependencies": {
"Moq": "4.2.1312.1622"
}
},
"dnxcore50": { }
}
}