diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/project.json b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/project.json index 1265cfa695..d52ce009b7 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/project.json +++ b/test/Microsoft.AspNet.Diagnostics.Entity.FunctionalTests/project.json @@ -1,16 +1,20 @@ { - "dependencies": { - "EntityFramework.MicrosoftSqlServer": "7.0.0-*", - "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*", - "Microsoft.AspNet.Diagnostics.Entity.Tests": "1.0.0", - "Microsoft.AspNet.TestHost": "1.0.0-*", - "Microsoft.AspNet.Testing": "1.0.0-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, - "commands": { - "test": "xunit.runner.aspnet" - }, - "frameworks": { - "dnx451": { } - } + "dependencies": { + "EntityFramework.MicrosoftSqlServer": "7.0.0-*", + "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*", + "Microsoft.AspNet.Diagnostics.Entity.Tests": "1.0.0", + "Microsoft.AspNet.TestHost": "1.0.0-*", + "Microsoft.AspNet.Testing": "1.0.0-*", + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, + "commands": { + "test": "xunit.runner.aspnet" + }, + "frameworks": { + "dnx451": { }, + "dnxcore50": { } + }, + "compilationOptions": { + "warningsAsErrors": true + } } diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.Tests/ApiConsistencyTest.cs b/test/Microsoft.AspNet.Diagnostics.Entity.Tests/ApiConsistencyTest.cs index 79f57a7997..363b8571b4 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.Tests/ApiConsistencyTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.Tests/ApiConsistencyTest.cs @@ -10,10 +10,7 @@ namespace Microsoft.AspNet.Diagnostics.EntityTests { public class ApiConsistencyTest : ApiConsistencyTestBase { - protected override Assembly TargetAssembly - { - get { return typeof(DatabaseErrorPageMiddleware).Assembly; } - } + protected override Assembly TargetAssembly => typeof(DatabaseErrorPageMiddleware).GetTypeInfo().Assembly; protected override IEnumerable GetCancellationTokenExceptions() { diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.Tests/ApiConsistencyTestBase.cs b/test/Microsoft.AspNet.Diagnostics.Entity.Tests/ApiConsistencyTestBase.cs index f5e7214453..d3fff1a5fe 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.Tests/ApiConsistencyTestBase.cs +++ b/test/Microsoft.AspNet.Diagnostics.Entity.Tests/ApiConsistencyTestBase.cs @@ -14,9 +14,9 @@ namespace Microsoft.Data.Entity { public abstract class ApiConsistencyTestBase { - private static readonly HashSet _typesToSkip = new HashSet + private static readonly HashSet _typesToSkip = new HashSet { - typeof(DatabaseErrorPage) + typeof(DatabaseErrorPage).GetTypeInfo() }; protected const BindingFlags PublicInstance @@ -29,15 +29,15 @@ namespace Microsoft.Data.Entity public void Public_inheritable_apis_should_be_virtual() { var nonVirtualMethods - = (from type in GetAllTypes(TargetAssembly.GetTypes()) + = (from type in GetAllTypes(TargetAssembly.DefinedTypes) where type.IsVisible && !type.IsSealed - && type.GetConstructors(AnyInstance).Any(c => c.IsPublic || c.IsFamily || c.IsFamilyOrAssembly) + && type.DeclaredConstructors.Any(c => c.IsPublic || c.IsFamily || c.IsFamilyOrAssembly) && type.Namespace != null && !type.Namespace.EndsWith(".Compiled") && !_typesToSkip.Contains(type) - from method in type.GetMethods(PublicInstance) - where method.DeclaringType == type + from method in type.DeclaredMethods.Where(m => m.IsPublic && !m.IsStatic) + where method.DeclaringType.GetTypeInfo() == type && !(method.IsVirtual && !method.IsFinal) select type.FullName + "." + method.Name) .ToList(); @@ -51,17 +51,17 @@ namespace Microsoft.Data.Entity public void Public_api_arguments_should_have_not_null_annotation() { var parametersMissingAttribute - = (from type in GetAllTypes(TargetAssembly.GetTypes()) - where type.IsVisible && !typeof(Delegate).IsAssignableFrom(type) && !_typesToSkip.Contains(type) - let interfaceMappings = type.GetInterfaces().Select(type.GetInterfaceMap) - let events = type.GetEvents() - from method in type.GetMethods(PublicInstance | BindingFlags.Static) - .Concat(type.GetConstructors()) - where method.DeclaringType == type + = (from type in GetAllTypes(TargetAssembly.DefinedTypes) + where type.IsVisible && !typeof(Delegate).GetTypeInfo().IsAssignableFrom(type) && !_typesToSkip.Contains(type) + let interfaceMappings = type.ImplementedInterfaces.Select(type.GetRuntimeInterfaceMap) + let events = type.DeclaredEvents + from method in type.DeclaredMethods.Where(m => m.IsPublic) + .Concat(type.DeclaredConstructors) + where method.DeclaringType.GetTypeInfo() == type where type.IsInterface || !interfaceMappings.Any(im => im.TargetMethods.Contains(method)) where !events.Any(e => e.AddMethod == method || e.RemoveMethod == method) from parameter in method.GetParameters() - where !parameter.ParameterType.IsValueType + where !parameter.ParameterType.GetTypeInfo().IsValueType && !parameter.GetCustomAttributes() .Any( a => a.GetType().Name == "NotNullAttribute" @@ -78,10 +78,10 @@ namespace Microsoft.Data.Entity public void Async_methods_should_have_overload_with_cancellation_token_and_end_with_async_suffix() { var asyncMethods - = (from type in GetAllTypes(TargetAssembly.GetTypes()) + = (from type in GetAllTypes(TargetAssembly.DefinedTypes) where type.IsVisible - from method in type.GetMethods(PublicInstance | BindingFlags.Static) - where method.DeclaringType == type + from method in type.DeclaredMethods.Where(m => m.IsPublic) + where method.DeclaringType.GetTypeInfo() == type where typeof(Task).IsAssignableFrom(method.ReturnType) select method).ToList(); @@ -99,7 +99,7 @@ namespace Microsoft.Data.Entity = (from methodWithoutToken in asyncMethodsWithoutToken where !asyncMethodsWithToken .Any(methodWithToken => methodWithoutToken.Name == methodWithToken.Name - && methodWithoutToken.ReflectedType == methodWithToken.ReflectedType) + && methodWithoutToken.DeclaringType == methodWithToken.DeclaringType) // ReSharper disable once PossibleNullReferenceException select methodWithoutToken.DeclaringType.Name + "." + methodWithoutToken.Name) .Except(GetCancellationTokenExceptions()) @@ -133,13 +133,13 @@ namespace Microsoft.Data.Entity protected abstract Assembly TargetAssembly { get; } - protected virtual IEnumerable GetAllTypes(IEnumerable types) + protected virtual IEnumerable GetAllTypes(IEnumerable typeInfos) { - foreach (var type in types) + foreach (var typeInfo in typeInfos) { - yield return type; + yield return typeInfo; - foreach (var nestedType in GetAllTypes(type.GetNestedTypes())) + foreach (var nestedType in GetAllTypes(typeInfo.DeclaredNestedTypes)) { yield return nestedType; } diff --git a/test/Microsoft.AspNet.Diagnostics.Entity.Tests/project.json b/test/Microsoft.AspNet.Diagnostics.Entity.Tests/project.json index 975e110626..db2a2a9331 100644 --- a/test/Microsoft.AspNet.Diagnostics.Entity.Tests/project.json +++ b/test/Microsoft.AspNet.Diagnostics.Entity.Tests/project.json @@ -1,15 +1,26 @@ { - "dependencies": { - "EntityFramework.InMemory": "7.0.0-*", - "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*", - "Moq": "4.2.1312.1622", - "xunit.runner.aspnet": "2.0.0-aspnet-*" + "compilationOptions": { + "warningsAsErrors": true + }, + "dependencies": { + "EntityFramework.InMemory": "7.0.0-*", + "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*", + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, + "compile": [ "../Shared/ApiConsistencyTestBase.cs", "../Shared/TestHelpers.cs" ], + "commands": { + "test": "xunit.runner.aspnet" + }, + "frameworks": { + "dnx451": { + "dependencies": { + "Moq": "4.2.1312.1622" + } }, - "compile": [ "..\\Shared\\ApiConsistencyTestBase.cs", "..\\Shared\\TestHelpers.cs" ], - "commands": { - "test": "xunit.runner.aspnet" - }, - "frameworks": { - "dnx451": { } + "dnxcore50": { + "dependencies": { + "moq.netcore": "4.4.0-beta8" + } } + } } diff --git a/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs b/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs index e16c100397..61a37d0e46 100644 --- a/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Tests/ElmMiddlewareTest.cs @@ -14,9 +14,7 @@ using Microsoft.AspNet.Http.Features.Internal; using Microsoft.AspNet.Http.Internal; using Microsoft.Extensions.Logging; using Microsoft.Extensions.OptionsModel; -#if DNX451 using Moq; -#endif using Xunit; namespace Microsoft.AspNet.Diagnostics.Tests @@ -35,7 +33,6 @@ namespace Microsoft.AspNet.Diagnostics.Tests Assert.Equal(DefaultPath, options.Path.Value); } -#if DNX451 [Fact] public async void Invoke_WithNonMatchingPath_IgnoresRequest() { @@ -226,7 +223,6 @@ namespace Microsoft.AspNet.Diagnostics.Tests .Returns(featureCollection); return contextMock; } -#endif [Fact] public async Task SetsNewIdentifierFeature_IfNotPresentOnContext() diff --git a/test/Microsoft.AspNet.Diagnostics.Tests/RuntimeInfoMiddlewareTest.cs b/test/Microsoft.AspNet.Diagnostics.Tests/RuntimeInfoMiddlewareTest.cs index c7a2e3f78a..0e4d5412bf 100644 --- a/test/Microsoft.AspNet.Diagnostics.Tests/RuntimeInfoMiddlewareTest.cs +++ b/test/Microsoft.AspNet.Diagnostics.Tests/RuntimeInfoMiddlewareTest.cs @@ -1,22 +1,17 @@ // 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.Linq; using System.Reflection; using System.Text; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.PlatformAbstractions; using Microsoft.Extensions.WebEncoders.Testing; -#if DNX451 using Moq; -#endif using Xunit; namespace Microsoft.AspNet.Diagnostics.Tests @@ -35,12 +30,11 @@ namespace Microsoft.AspNet.Diagnostics.Tests Assert.Equal(DefaultPath, options.Path.Value); } -#if DNX451 [Fact] public void CreateRuntimeInfoModel_GetsTheVersionAndAllPackages() { // Arrage - var libraries = new [] { + var libraries = new[] { new Library("LibInfo1", string.Empty, "Path1", string.Empty, Enumerable.Empty(), Enumerable.Empty()), new Library("LibInfo2", string.Empty, "Path2", string.Empty, Enumerable.Empty(), Enumerable.Empty()) }; @@ -111,7 +105,7 @@ namespace Microsoft.AspNet.Diagnostics.Tests { // Arrange var libraryManagerMock = new Mock(MockBehavior.Strict); - libraryManagerMock.Setup(l => l.GetLibraries()).Returns(new [] { + libraryManagerMock.Setup(l => l.GetLibraries()).Returns(new[] { new Library("LibInfo1", "1.0.0-beta1", "Path1", string.Empty, Enumerable.Empty(), Enumerable.Empty()), new Library("LibInfo2", "1.0.0-beta2", "Path2", string.Empty, Enumerable.Empty(), Enumerable.Empty()) }); @@ -171,7 +165,7 @@ namespace Microsoft.AspNet.Diagnostics.Tests { // Arrange var libraryManagerMock = new Mock(MockBehavior.Strict); - libraryManagerMock.Setup(l => l.GetLibraries()).Returns(new [] { + libraryManagerMock.Setup(l => l.GetLibraries()).Returns(new[] { new Library("LibInfo1", "1.0.0-beta1", "Path1", string.Empty, Enumerable.Empty(), Enumerable.Empty()), }); @@ -219,6 +213,5 @@ namespace Microsoft.AspNet.Diagnostics.Tests Assert.True(response.Contains("HtmlEncode[[Path1]]")); } } -#endif } } diff --git a/test/Microsoft.AspNet.Diagnostics.Tests/project.json b/test/Microsoft.AspNet.Diagnostics.Tests/project.json index 35a8d7a1a4..13f90a8436 100644 --- a/test/Microsoft.AspNet.Diagnostics.Tests/project.json +++ b/test/Microsoft.AspNet.Diagnostics.Tests/project.json @@ -1,31 +1,34 @@ { - "compilationOptions": { - "warningsAsErrors": false, - "keyFile": "../../tools/Key.snk" - }, - "dependencies": { - "Microsoft.AspNet.Diagnostics.Elm": "1.0.0-*", - "Microsoft.AspNet.FileProviders.Embedded": "1.0.0-*", - "Microsoft.AspNet.TestHost": "1.0.0-*", - "Microsoft.AspNet.Testing": "1.0.0-*", - "Microsoft.Extensions.DependencyInjection": "1.0.0-*", - "Microsoft.Extensions.DiagnosticAdapter": "1.0.0-*", - "xunit.runner.aspnet": "2.0.0-aspnet-*" - }, + "compilationOptions": { + "warningsAsErrors": true, + "keyFile": "../../tools/Key.snk" + }, + "dependencies": { + "Microsoft.AspNet.Diagnostics.Elm": "1.0.0-*", + "Microsoft.AspNet.FileProviders.Embedded": "1.0.0-*", + "Microsoft.AspNet.TestHost": "1.0.0-*", + "Microsoft.AspNet.Testing": "1.0.0-*", + "Microsoft.Extensions.DependencyInjection": "1.0.0-*", + "Microsoft.Extensions.DiagnosticAdapter": "1.0.0-*", + "xunit.runner.aspnet": "2.0.0-aspnet-*" + }, - "frameworks": { - "dnx451": { - "dependencies": { - "Moq": "4.2.1312.1622" - } - }, - "dnxcore50": { - } + "frameworks": { + "dnx451": { + "dependencies": { + "Moq": "4.2.1312.1622" + } }, + "dnxcore50": { + "dependencies": { + "moq.netcore": "4.4.0-beta8" + } + } + }, - "commands": { - "test": "xunit.runner.aspnet" - }, + "commands": { + "test": "xunit.runner.aspnet" + }, - "resource": [ "Resources/**" ] + "resource": [ "Resources/**" ] }