Created
February 23, 2016 16:56
-
-
Save aienabled/e7163af9625791548247 to your computer and use it in GitHub Desktop.
TestAqlaInheritanceSerialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestClass] | |
public class TestAqlaInheritanceSerialization | |
{ | |
[TestMethod] | |
public void Test() | |
{ | |
var testValue = 777; | |
var obj = new TestClass(testValue); | |
var result = Serializer.DeepClone(obj); | |
Assert.AreEqual(testValue, result.GetPrivateFieldValue()); | |
var obj2 = new TestClass2(testValue); | |
var result2 = Serializer.DeepClone(obj2); | |
// expection "The type cannot be changed once a serializer has been generated" thrown here | |
Assert.AreEqual(testValue, result2.GetPrivateFieldValue()); | |
} | |
} | |
[SerializableType(ImplicitFields = ImplicitFieldsMode.AllFieldsAndProperties)] | |
public class TestClass : BaseTestClass | |
{ | |
public TestClass(int testField) : base(testField) | |
{ | |
} | |
} | |
[SerializableType(ImplicitFields = ImplicitFieldsMode.AllFieldsAndProperties)] | |
public class TestClass2 : BaseTestClass | |
{ | |
public TestClass2(int testField) : base(testField) | |
{ | |
} | |
} | |
[SerializableType(ImplicitFields = ImplicitFieldsMode.AllFieldsAndProperties)] | |
public class BaseTestClass | |
{ | |
private int testField; | |
public BaseTestClass(int testField) | |
{ | |
this.testField = testField; | |
} | |
public int GetPrivateFieldValue() | |
{ | |
return this.testField; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment