Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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
        }