Exemple #1
0
        public void EditableObjectModelBase_EditableObjectTest()
        {
            var person = new EditablePerson();

            person.FirstName = "Albert";
            person.Age       = 10;
            person.Boss.Age  = 99;
            person.AcceptChanges();

            Assert.IsFalse(person.IsChangedLocal);

            person.BeginEdit();
            Assert.IsFalse(person.IsChangedLocal);
            person.FirstName = "Bob";
            Assert.IsTrue(person.IsChangedLocal);
            Assert.AreEqual("Bob", person.FirstName);
            person.CancelEdit();

            Assert.AreEqual("Albert", person.FirstName);
            Assert.AreEqual(10, person.Age);
            Assert.IsFalse(person.IsChangedLocal);


            person.BeginEdit();
            Assert.IsFalse(person.IsChangedLocal);
            person.FirstName = "Chris";
            Assert.IsTrue(person.IsChangedLocal);
            Assert.AreEqual("Chris", person.FirstName);

            person.EndEdit();
            Assert.IsTrue(person.IsChangedLocal);
            Assert.AreEqual("Chris", person.FirstName);

            person.BeginEdit();
            Assert.IsTrue(person.IsChangedLocal);
            person.FirstName = "David";
            Assert.IsTrue(person.IsChangedLocal);
            Assert.AreEqual("David", person.FirstName);

            person.EndEdit();
            Assert.IsTrue(person.IsChangedLocal);
            Assert.AreEqual("David", person.FirstName);


            person.BeginEdit();
            person.BeginEdit();

            person.EndEdit();
            person.EndEdit();

            person.BeginEdit();
            person.BeginEdit();

            person.CancelEdit();
            person.CancelEdit();
        }