public void TryResolveGenericMethod_WithArgumentsNotMatchingTypeConstraint_ReturnsFalse() { var typeArgs = new[] { typeof(IEnumerable <int>), typeof(bool), typeof(string), typeof(Tuple <int, Func <bool, Guid> >), typeof(Guid) }; MethodInfo methodInstance; Assert.That(GenericTestMethodInfo.TryResolveGenericMethod(typeArgs, out methodInstance), Is.False); }
public void TryResolveGenericMethod_WithArgumentsNotMatchingStructConstraint_ReturnsFalse() { // type AppDomain does not satisfy TStruct: struct var typeArgs = new[] { typeof(IEnumerable <int>), typeof(MemoryStream), typeof(string), typeof(Tuple <int, Func <MemoryStream, bool?> >), typeof(bool?) }; MethodInfo methodInstance; Assert.That(GenericTestMethodInfo.TryResolveGenericMethod(typeArgs, out methodInstance), Is.False); }
public void TryResolveGenericMethod_WithSomeArgumentsInherited_ResolvesMethod() { var typeArgs = new[] { typeof(IGrouping <Uri, int>), typeof(MemoryStream), typeof(string), typeof(Tuple <int, Func <MemoryStream, Guid> >), typeof(Guid) }; MethodInfo methodInstance; Assert.That(GenericTestMethodInfo.TryResolveGenericMethod(typeArgs, out methodInstance), Is.EqualTo(true)); Assert.That(methodInstance.GetGenericArguments(), Is.EquivalentTo(new[] { typeof(int), typeof(MemoryStream), typeof(Guid) })); }
public void TryResolveGenericMethod_WithPerfectlyMatchingArguments_ResolvesMethod() { // Should make GenericTestMethodInfo instance with <int,MemoryStream,Guid> var typeArgs = new[] { typeof(IEnumerable <int>), typeof(MemoryStream), typeof(string), typeof(Tuple <int, Func <MemoryStream, Guid> >), typeof(Guid) }; MethodInfo methodInstance; Assert.That(GenericTestMethodInfo.TryResolveGenericMethod(typeArgs, out methodInstance), Is.EqualTo(true)); Assert.That(methodInstance.GetGenericArguments(), Is.EquivalentTo(new[] { typeof(int), typeof(MemoryStream), typeof(Guid) })); }