public void InitializeEmptyTest() { var obj = new StoredObj(); Assert.That(obj.Main, Is.Null); obj.DeserializeMain(); // implicitly new() Assert.That(obj.Main, Is.Not.Null); Assert.That(obj.Exposed, Is.Null); // not yet copied obj.LoadMembers(); Assert.That(obj.Exposed, Is.EqualTo(TESTVALUE)); }
public void SerializeDeserializeTest() { var obj = new StoredObj(); Assert.That(obj.Main, Is.Null); obj.Main = new TestObj(); // instantiate Main explicitly obj.SerializeMain(); obj.Main = null; // delete Main obj.DeserializeMain(); // reconstruct Main from ViewState Assert.That(obj.Main, Is.Not.Null); obj.LoadMembers(); // expose the reconstructed members Assert.That(obj.Exposed, Is.EqualTo(TESTVALUE)); }
public void SerializeDeserializeModifyTest() { const string NEWVALUE = "<some new string>"; var obj = new StoredObj(); Assert.That(obj.Main, Is.Null); obj.Main = new TestObj(); obj.SerializeMain(); // Main with the original values obj.Main = null; obj.Exposed = NEWVALUE; // modify an exposed value on the client without a Main instance obj.DeserializeMain(); // reconstruct Main with the old value from ViewState obj.SaveMembers(); // mirror the changed values without LoadMembers() Assert.That(obj.Main, Is.Not.Null); Assert.That(obj.Exposed, Is.EqualTo(NEWVALUE)); // set Assert.That(obj.Main.Embedded, Is.EqualTo(NEWVALUE)); // mirrored }