/// <summary> /// Extend the entity with an extension object, excluding the entity properties /// </summary> /// <param name="extension"></param> public SeededEntityWrapper <T> ExtendWith(T extension) { var entityProperties = typeof(Entity).GetProperties(); TypeReflectionToolbox.CopyPublicProperties(extension, Data, entityProperties.ToList()); return(this); }
public void ReflectionCopy_ShouldCopy_PropertyValues() { // ARRANGE var source = new InternalTestChild() { BaseProp = "BaseProp", ChildProp = "ChildProp" }; var destination = new InternalTestChild(); // ACT TypeReflectionToolbox.CopyPublicProperties(source, destination); //ASSERT Assert.AreEqual(source.BaseProp, destination.BaseProp); Assert.AreEqual(source.ChildProp, destination.ChildProp); }
public void ReflectionCopy_ShouldNotCopy_ExcludedValues() { // ARRANGE var source = new InternalTestChild() { BaseProp = "BaseProp", ChildProp = "ChildProp" }; var destination = new InternalTestChild() { BaseProp = "OriginalBaseProp" }; var baseProperties = typeof(InternalTestBase).GetProperties(); // ACT TypeReflectionToolbox.CopyPublicProperties(source, destination, baseProperties.ToList()); //ASSERT Assert.AreNotEqual(source.BaseProp, destination.BaseProp); Assert.AreEqual(destination.BaseProp, "OriginalBaseProp"); Assert.AreEqual(source.ChildProp, destination.ChildProp); }