public void MemberInfoSlimVisitor_VisitGenericMethod_AreNotSame() { var visitor = new A(); var genDef = SlimType.GetGenericDefinitionMethod("Foo", new TypeSlim[] { TypeSlim.GenericParameter("T") }.ToReadOnly(), EmptyReadOnlyCollection <TypeSlim> .Instance, returnType: null); var generic = SlimType.GetGenericMethod(genDef, new TypeSlim[] { SlimType }.ToReadOnly()); Assert.AreNotSame(generic, visitor.Visit(generic)); }
public void GenericMethodInfoSlim_ArgumentChecks() { AssertEx.ThrowsException <ArgumentNullException>(() => TypeSlimExtensions.GetGenericMethod(type: null, methodDefinition: null, arguments: null), ex => Assert.AreEqual("type", ex.ParamName)); AssertEx.ThrowsException <ArgumentNullException>(() => SlimType.GetGenericMethod(methodDefinition: null, arguments: null), ex => Assert.AreEqual("methodDefinition", ex.ParamName)); var def = SlimType.GetGenericDefinitionMethod("Foo", new List <TypeSlim> { SlimType }.AsReadOnly(), EmptyReadOnlyCollection <TypeSlim> .Instance, returnType: null); AssertEx.ThrowsException <ArgumentNullException>(() => def.DeclaringType.GetGenericMethod(def, arguments: null), ex => Assert.AreEqual("arguments", ex.ParamName)); }
public void MemberInfoSlimVisitor_Generic_GenericMethod() { var visitor = new MyVisitor(); var genDef = SlimType.GetGenericDefinitionMethod("Foo", new TypeSlim[] { TypeSlim.GenericParameter("T") }.ToReadOnly(), EmptyReadOnlyCollection <TypeSlim> .Instance, returnType: null); var generic = SlimType.GetGenericMethod(genDef, new TypeSlim[] { SlimType }.ToReadOnly()); var res = visitor.Visit(generic); Assert.AreEqual(42, res); }