public void CreateMappingCollection_Verify_Private_Properties_Mapped() { var myObject = new MyTestClass(); var result = ObjectFieldMappingCollection.CreateMappingCollection(myObject); Assert.NotNull(result.GetFieldInfo("B")); }
public static ObjectFieldMappingCollection CreateMappingCollection(object sourceObject) { var sourceObjectType = sourceObject.GetType(); var fieldMappingCollection = new ObjectFieldMappingCollection(sourceObjectType); foreach (var property in sourceObjectType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { fieldMappingCollection.AddFieldMapping(property.Name, property); } return(fieldMappingCollection); }
public void CreateMappingCollection_Verify_NonExistent_Properties_Not_Mapped() { var myObject = new { Property1 = "a", Property2 = "b" }; var result = ObjectFieldMappingCollection.CreateMappingCollection(myObject); Assert.Null(result.GetFieldInfo("Property3")); }