public void Shouldnt_Serialize_NotSettable_Properties() { var testObj = new TestClass3 { Field1 = 100, Prop1 = new TesClass2 { Prop1 = new TestClass1 { Prop1 = "Test 1", Prop2 = 23423 }, Prop2 = "Test 2", Prop3 = 423432 }, Prop2 = "Test 3", Prop3 = 657567565, Prop6 = 200 }; testObj.SetProp5(110); Serializer.RegisterTypes(new[] { typeof(TestClass3) }); using (var stream = new MemoryStream()) { Serializer.Serialize(stream, testObj); stream.Seek(0, SeekOrigin.Begin); var result = Serializer.Deserialize <TestClass3>(stream); Assert.IsType(testObj.GetType(), result); Assert.Equal(testObj, result); Assert.Equal(result.Prop3 + 10, result.Prop4); Assert.Equal(0, result.Prop5); Assert.Equal(0, result.Field1); Assert.Equal(0, result.Prop6); } }
public void Should_Serialize_Complex_Object() { var testObj = new TestClass3 { Prop1 = new TesClass2 { Prop1 = new TestClass1 { Prop1 = "Test 1", Prop2 = 23423 }, Prop2 = "Test 2", Prop3 = 423432 }, Prop2 = "Test 3", Prop3 = 657567565 }; Serializer.RegisterTypes(new[] { typeof(TestClass3) }); using (var stream = new MemoryStream()) { Serializer.Serialize(stream, testObj); stream.Seek(0, SeekOrigin.Begin); var result = Serializer.Deserialize(stream); Assert.IsType(testObj.GetType(), result); Assert.Equal(result, testObj); } }