public void CanCreateClosedParameterTypeFromOpenOne() { MethodBase m = typeof(LoggingCommand <>).GetTypeInfo().DeclaredConstructors.ElementAt(0); ParameterReflectionHelper helper = new ParameterReflectionHelper( m.GetParameters()[0]); Type closedType = helper.GetClosedParameterType(typeof(LoggingCommand <User>).GenericTypeArguments); Assert.IsType <ICommand <User> >(closedType); }
public void CanCreateClosedParameterTypeFromOpenOne() { MethodBase m = typeof(LoggingCommand <>).GetConstructors()[0]; ParameterReflectionHelper helper = new ParameterReflectionHelper( m.GetParameters()[0]); Type closedType = helper.GetClosedParameterType(typeof(LoggingCommand <User>).GetGenericArguments()); Assert.AreSame(typeof(ICommand <User>), closedType); }
public void ClosingParameterTypesReturnsOriginalTypeWhenItIsClosed() { MethodBase m = typeof(User).GetTypeInfo().GetDeclaredMethod("DoSomething"); ParameterInfo[] methodParams = m.GetParameters(); Assert.Equal(1, methodParams.Length); ParameterReflectionHelper helper = new ParameterReflectionHelper(methodParams[0]); Assert.IsType <string>(helper.GetClosedParameterType(new Type[0])); }