public void CopyPropertiesFromInstance_ThrowsExceptionOnDifferingInstanceTypes() { var animal = new TestClassAnimal("Tiger", true); var car = new TestClassCar("Kia Rio", false); // Ensure the copying throws an exception indicating you can't copy across types. Assert.ThrowsException <ReflectionTypeLoadException>(() => { animal.CopyPropertiesFromInstance(car); }); }
public void CopyPropertiesFromInstance_PropertiesCopyAcrossClassesSuccessfully() { // Create the instances. We'll ensure the second class is different enough. var animalOne = new TestClassAnimal(null, false); var animalTwo = new TestClassAnimal("Tiger", true); // Copy the values, and assert it was done correctly. animalOne.CopyPropertiesFromInstance(animalTwo); Assert.AreEqual(animalOne.AnimalName, animalTwo.AnimalName); Assert.AreEqual(animalOne.IsMammal, animalTwo.IsMammal); }