public void WrappedInterfaceHasWrappedGenericMethods2() { var source = typeof(IGenericInterface); var wrapped = GenericInterfaceWrapper.Wrap(source); var mi = source.GetMethod("DoSomething"); var newName = GenericInterfaceWrapper.GetWrappedName(mi); mi = wrapped.GetMethod(newName); Assert.IsNotNull(mi); var parameters = mi.GetParameters(); Assert.AreEqual(6, parameters.Length); Assert.AreEqual(typeof(void), mi.ReturnType); // generic parameters Assert.AreEqual(typeof(Type), parameters[0].ParameterType); Assert.AreEqual(typeof(Type), parameters[1].ParameterType); Assert.AreEqual(typeof(Type), parameters[2].ParameterType); // method arguments Assert.AreEqual(typeof(object), parameters[3].ParameterType); Assert.AreEqual(typeof(object), parameters[4].ParameterType); Assert.AreEqual(typeof(object), parameters[5].ParameterType); }
public void WrappedInterfaceIsNotSame() { var source = typeof(IGenericInterface); var wrapped = GenericInterfaceWrapper.Wrap(source); Assert.IsNotNull(wrapped); Assert.AreNotEqual(source, wrapped); Assert.AreEqual(source.FullName, wrapped.FullName); }
public void WrappedInterfaceHasSameNonGenericMethods() { var source = typeof(IGenericInterface); var wrapped = GenericInterfaceWrapper.Wrap(source); foreach (var sm in source.GetMethods()) { if (!sm.IsGenericMethod) { var wm = wrapped.GetMethod(sm.Name); Assert.IsNotNull(wm); Assert.AreEqual(sm.ToString(), wm.ToString()); } } }
public void WrappedInterfaceHasEvents() { var source = typeof(IGenericInterface); var wrapped = GenericInterfaceWrapper.Wrap(source); var ev1 = source.GetEvent("OnPrioritySet"); Assert.IsNotNull(ev1); Assert.IsNotNull(ev1.GetAddMethod()); Assert.IsNotNull(ev1.GetRemoveMethod()); Assert.AreEqual(ev1.EventHandlerType, typeof(EventHandler <EventArgs>)); var ev2 = wrapped.GetEvent("OnPrioritySet"); Assert.IsNotNull(ev2); Assert.IsNotNull(ev2.GetAddMethod()); Assert.IsNotNull(ev2.GetRemoveMethod()); Assert.AreEqual(ev2.EventHandlerType, typeof(EventHandler <EventArgs>)); }
public void WrappedInterfaceHasProperties3() { var source = typeof(IGenericInterface); var wrapped = GenericInterfaceWrapper.Wrap(source); var pi1 = source.GetProperty("Priority"); Assert.IsNotNull(pi1); Assert.IsNull(pi1.GetGetMethod()); Assert.IsNotNull(pi1.GetSetMethod()); Assert.AreEqual(pi1.PropertyType, typeof(int)); var pi2 = wrapped.GetProperty("Priority"); Assert.IsNotNull(pi2); Assert.IsNull(pi2.GetGetMethod()); Assert.IsNotNull(pi2.GetSetMethod()); Assert.AreEqual(pi2.PropertyType, typeof(int)); }