public void ChangeTrackingModelBase_SerializationTest1()
        {
            var person = new ChangeTrackingPerson();

            person.FirstName = "Tom";
            person.LastName  = "Jones";
            person.AcceptChanges();

            var stream     = new MemoryStream();
            var serializer = new DataContractSerializer(typeof(ChangeTrackingPerson));

            serializer.WriteObject(stream, person);
            stream.Position = 0;
            var newPerson = (ChangeTrackingPerson)serializer.ReadObject(stream);

            Assert.AreEqual(person.FirstName, newPerson.FirstName);
            Assert.AreEqual(person.LastName, newPerson.LastName);
            Assert.AreEqual(person.FullName, newPerson.FullName);
            Assert.AreEqual(person.IsChangedLocal, newPerson.IsChangedLocal);
        }
        public void ChangeTrackingModelBase_ChangeTrackingTest()
        {
            var person = new ChangeTrackingPerson();

            person.RejectChanges();

            Assert.IsNotNull(person.Boss);
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsFalse(person.IsChanged);

            person.Age = 100;
            Assert.IsTrue(person.IsChangedLocal);
            Assert.IsTrue(person.IsChanged);
            person.RejectChanges();

            Assert.AreEqual(0, person.Age);
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsFalse(person.IsChanged);


            person.FirstName = "Tom";
            Assert.IsTrue(person.IsChangedLocal);
            Assert.IsTrue(person.IsChanged);

            person.AcceptChanges();
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsFalse(person.IsChanged);
            Assert.IsFalse(person.Boss.IsChangedLocal);
            Assert.IsFalse(person.Boss.IsChanged);

            person.Boss.FirstName = "Frank";
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsTrue(person.IsChanged);
            Assert.IsTrue(person.Boss.IsChangedLocal);
            Assert.IsTrue(person.Boss.IsChanged);
            Assert.AreEqual("Tom", person.FirstName);
            Assert.AreEqual("Frank", person.Boss.FirstName);

            person.AcceptChanges();
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsFalse(person.IsChanged);
            Assert.IsFalse(person.Boss.IsChangedLocal);
            Assert.IsFalse(person.Boss.IsChanged);
            Assert.AreEqual("Tom", person.FirstName);
            Assert.AreEqual("Frank", person.Boss.FirstName);

            person.FirstName      = "Harry";
            person.Boss.FirstName = "Sam";
            Assert.IsTrue(person.IsChangedLocal);
            Assert.IsTrue(person.IsChanged);
            Assert.IsTrue(person.Boss.IsChangedLocal);
            Assert.IsTrue(person.Boss.IsChanged);
            Assert.AreEqual("Harry", person.FirstName);
            Assert.AreEqual("Sam", person.Boss.FirstName);

            person.RejectChanges();
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsFalse(person.IsChanged);
            Assert.IsFalse(person.Boss.IsChangedLocal);
            Assert.IsFalse(person.Boss.IsChanged);
            Assert.AreEqual("Tom", person.FirstName);
            Assert.AreEqual("Frank", person.Boss.FirstName);

            person.DummyObject.IsChanged = true;
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsTrue(person.IsChanged);

            person.AcceptChanges();
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsFalse(person.IsChanged);

            person.DummyObject.IsChanged = true;
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsTrue(person.IsChanged);

            person.RejectChanges();
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsFalse(person.IsChanged);


            person.DummyObject.IsChanged = true;
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsTrue(person.IsChanged);

            person.AcceptChangesLocal();
            Assert.IsFalse(person.IsChangedLocal);
            Assert.IsTrue(person.IsChanged);
        }