Skip tests that are failing due to Mono issues

Fixes #214
This commit is contained in:
Pranav K 2015-12-01 09:48:35 -08:00
parent f0c2d7ed25
commit ca62719f9d
2 changed files with 47 additions and 42 deletions

View File

@ -8,6 +8,7 @@ using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNet.Diagnostics.Entity.Views;
using Microsoft.AspNet.Testing.xunit;
using Xunit;
namespace Microsoft.Data.Entity
@ -25,21 +26,22 @@ namespace Microsoft.Data.Entity
protected const BindingFlags AnyInstance
= BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
[Fact]
[ConditionalFact(Skip = "Skipping until we update to mono")]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
public void Public_inheritable_apis_should_be_virtual()
{
var nonVirtualMethods
= (from type in GetAllTypes(TargetAssembly.DefinedTypes)
where type.IsVisible
&& !type.IsSealed
&& type.DeclaredConstructors.Any(c => c.IsPublic || c.IsFamily || c.IsFamilyOrAssembly)
&& type.Namespace != null
&& !type.Namespace.EndsWith(".Compiled")
&& !_typesToSkip.Contains(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)
where type.IsVisible
&& !type.IsSealed
&& type.DeclaredConstructors.Any(c => c.IsPublic || c.IsFamily || c.IsFamilyOrAssembly)
&& type.Namespace != null
&& !type.Namespace.EndsWith(".Compiled")
&& !_typesToSkip.Contains(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();
Assert.False(
@ -47,26 +49,27 @@ namespace Microsoft.Data.Entity
"\r\n-- Missing virtual APIs --\r\n" + string.Join("\r\n", nonVirtualMethods));
}
[Fact]
[ConditionalFact(Skip = "Skipping until we update to mono")]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
public void Public_api_arguments_should_have_not_null_annotation()
{
var parametersMissingAttribute
= (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<MethodBase>(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.GetTypeInfo().IsValueType
&& !parameter.GetCustomAttributes()
.Any(
a => a.GetType().Name == "NotNullAttribute"
|| a.GetType().Name == "CanBeNullAttribute")
select type.FullName + "." + method.Name + "[" + parameter.Name + "]")
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<MethodBase>(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.GetTypeInfo().IsValueType
&& !parameter.GetCustomAttributes()
.Any(
a => a.GetType().Name == "NotNullAttribute"
|| a.GetType().Name == "CanBeNullAttribute")
select type.FullName + "." + method.Name + "[" + parameter.Name + "]")
.ToList();
Assert.False(
@ -74,34 +77,35 @@ namespace Microsoft.Data.Entity
"\r\n-- Missing NotNull annotations --\r\n" + string.Join("\r\n", parametersMissingAttribute));
}
[Fact]
[ConditionalFact(Skip = "Skipping until we update to mono")]
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
public void Async_methods_should_have_overload_with_cancellation_token_and_end_with_async_suffix()
{
var asyncMethods
= (from type in GetAllTypes(TargetAssembly.DefinedTypes)
where type.IsVisible
from method in type.DeclaredMethods.Where(m => m.IsPublic)
where method.DeclaringType.GetTypeInfo() == type
where typeof(Task).IsAssignableFrom(method.ReturnType)
select method).ToList();
where type.IsVisible
from method in type.DeclaredMethods.Where(m => m.IsPublic)
where method.DeclaringType.GetTypeInfo() == type
where typeof(Task).IsAssignableFrom(method.ReturnType)
select method).ToList();
var asyncMethodsWithToken
= (from method in asyncMethods
where method.GetParameters().Any(pi => pi.ParameterType == typeof(CancellationToken))
select method).ToList();
where method.GetParameters().Any(pi => pi.ParameterType == typeof(CancellationToken))
select method).ToList();
var asyncMethodsWithoutToken
= (from method in asyncMethods
where method.GetParameters().All(pi => pi.ParameterType != typeof(CancellationToken))
select method).ToList();
where method.GetParameters().All(pi => pi.ParameterType != typeof(CancellationToken))
select method).ToList();
var missingOverloads
= (from methodWithoutToken in asyncMethodsWithoutToken
where !asyncMethodsWithToken
.Any(methodWithToken => methodWithoutToken.Name == methodWithToken.Name
&& methodWithoutToken.DeclaringType == methodWithToken.DeclaringType)
// ReSharper disable once PossibleNullReferenceException
select methodWithoutToken.DeclaringType.Name + "." + methodWithoutToken.Name)
where !asyncMethodsWithToken
.Any(methodWithToken => methodWithoutToken.Name == methodWithToken.Name
&& methodWithoutToken.DeclaringType == methodWithToken.DeclaringType)
// ReSharper disable once PossibleNullReferenceException
select methodWithoutToken.DeclaringType.Name + "." + methodWithoutToken.Name)
.Except(GetCancellationTokenExceptions())
.ToList();

View File

@ -5,6 +5,7 @@
"dependencies": {
"EntityFramework.InMemory": "7.0.0-*",
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*",
"Microsoft.AspNet.Testing": "1.0.0-*",
"xunit.runner.aspnet": "2.0.0-aspnet-*"
},
"compile": [ "../Shared/ApiConsistencyTestBase.cs", "../Shared/TestHelpers.cs" ],