public CustomAssemblyTests() { var customReflectionContext = new TestCustomReflectionContext(); Assembly assembly = typeof(CustomAssemblyTests).Assembly; _customAssembly = customReflectionContext.MapAssembly(assembly); }
public CustomPropertyInfoTests() { var customReflectionContext = new TestCustomReflectionContext(); TypeInfo typeInfo = typeof(TestObject).GetTypeInfo(); TypeInfo customTypeInfo = customReflectionContext.MapType(typeInfo); IEnumerable <PropertyInfo> customProperties = customTypeInfo.DeclaredProperties; _customProperty = customProperties.First(); }
public void EqualsTest() { var customReflectionContext = new TestCustomReflectionContext(); Assembly assembly = typeof(CustomAssemblyTests).Assembly; Assembly customAssembly = customReflectionContext.MapAssembly(assembly); // Projector is not the same. Assert.NotEqual(customAssembly, _customAssembly); }
public void MapType_MemberAttributes_Success() { var customReflectionContext = new TestCustomReflectionContext(); TypeInfo typeInfo = typeof(TestObject).GetTypeInfo(); TypeInfo customTypeInfo = customReflectionContext.MapType(typeInfo); MemberInfo customMemberInfo = customTypeInfo.GetDeclaredMethod("GetMessage"); IEnumerable <Attribute> results = customMemberInfo.GetCustomAttributes(); Assert.Single(results); Assert.IsType <TestAttribute>(results.First()); }
public void MapType_Interface_Throws() { var customReflectionContext = new TestCustomReflectionContext(); TypeInfo typeInfo = typeof(ICloneable).GetTypeInfo(); TypeInfo customTypeInfo = customReflectionContext.MapType(typeInfo); MethodInfo customMemberInfo = customTypeInfo.GetDeclaredMethod("Clone"); IEnumerable <Attribute> results = customMemberInfo.GetCustomAttributes(); Assert.Empty(results); IEnumerable <PropertyInfo> props = customTypeInfo.DeclaredProperties; Assert.Empty(props); }
public void MapType_ParameterAttributes_Success() { var customReflectionContext = new TestCustomReflectionContext(); TypeInfo typeInfo = typeof(TestObject).GetTypeInfo(); TypeInfo customTypeInfo = customReflectionContext.MapType(typeInfo); ConstructorInfo ctor = customTypeInfo.GetConstructor(new Type[] { typeof(string) }); ParameterInfo[] parameters = ctor.GetParameters(); Assert.Single(parameters); IEnumerable <Attribute> results = parameters[0].GetCustomAttributes(); Assert.Single(results); Assert.IsType <TestAttribute>(results.First()); }
public void MapType_Null_Throws() { var customReflectionContext = new TestCustomReflectionContext(); AssertExtensions.Throws <ArgumentNullException>("type", () => customReflectionContext.MapType(null)); }