public void FactoryRefRead() { // This is an error because a .WithFactory() method is being called, which precludes references. string serialized = @" <Record> <recordFormatVersion>1</recordFormatVersion> <refs> <Ref id=""ref00000"" class=""DecTest.RecorderFactory.RecorderHybrid""> <recorded>99</recorded> </Ref> </refs> <data> <one ref=""ref00000"" /> <two> <recorded>42</recorded> </two> </data> </Record>"; SharedWriteCode deserialized = null; ExpectErrors(() => deserialized = Dec.Recorder.Read <SharedWriteCode>(serialized)); Assert.IsNotNull(deserialized.one); Assert.AreEqual(0, deserialized.one.nonrecorded); Assert.AreEqual(99, deserialized.one.recorded); Assert.IsNotNull(deserialized.two); Assert.AreEqual(100, deserialized.two.nonrecorded); Assert.AreEqual(42, deserialized.two.recorded); }
public void SharedWrite([Values] RecorderMode mode) { var element = new SharedWriteCode(); element.one = new RecorderHybrid(); element.two = element.one; element.one.nonrecorded = 11; element.one.recorded = 12; var deserialized = DoRecorderRoundTrip(element, mode, expectWriteErrors: true); Assert.IsNotNull(deserialized.one); Assert.AreEqual(100, deserialized.one.nonrecorded); Assert.AreEqual(12, deserialized.one.recorded); Assert.IsNotNull(deserialized.two); Assert.AreEqual(100, deserialized.two.nonrecorded); Assert.AreEqual(200, deserialized.two.recorded); }