Inheritance: IChangeTracking
Exemple #1
0
 public void CanStoreAnyPropertyData()
 {
     dynamic person = new Person();
     Assert.AreEqual(1, person.Age);
     Assert.IsNull(person.Name);
     person.Name = "Bob";
     Assert.AreEqual("Bob", person.Name);
 }
 public void Init()
 {
     person = new Person
     {
         FirstName = "Bob",
         LastName = "Minion",
         DateOfBirth = DateTime.Parse("11/11/11"),
     };
 }
Exemple #3
0
 public void Init()
 {
     Person = new Person
     {
         FirstName = "Bill",
         LastName = "Klingon",
         DateOfBirth = DateTime.Parse("11/11/11"),
     };
 }
Exemple #4
0
 public void CanBeCloned()
 {
     dynamic person = new Person();
     person.Name = "Bob";
     dynamic clone = ((ICloneable) person).Clone();
     var cloneMixin = (ICloneable) clone;
     Assert.AreNotSame(clone, person);
     Assert.AreEqual(clone.Name, person.Name);
     Assert.IsTrue(cloneMixin.EqualsByValue((IMixin) person));
 }
Exemple #5
0
        public void EqualsByValueWorks()
        {
            dynamic foo = new Person();
            var fooMixin = (IMixin)foo;
            foo.Name = "Bob";
            dynamic bar = new Person();
            bar.Name = "Bob";
            Assert.IsTrue(fooMixin.EqualsByValue((IMixin)bar));

            bar.Tag = 1;
            Assert.IsFalse(fooMixin.EqualsByValue((IMixin)bar));
        }
Exemple #6
0
        public void ListItemChangesBubbleUpToParent()
        {
            Person.FirstName = "Parent";
            var child = new Person { FirstName = "Child" };
            child.Friends.Add(new Person { FirstName = "Grandchild" });
            Person.Friends.Add(child);

            Person.StartTrackingChanges();
            var friendOfFriend = Person.Friends[0].Friends[0];
            var oldName = friendOfFriend.FirstName;
            friendOfFriend.FirstName = "New";
            Assert.IsTrue(Person.IsChanged);
            Assert.IsTrue(friendOfFriend.IsChanged);
            friendOfFriend.FirstName = oldName;
            Assert.IsFalse(Person.IsChanged);
            Assert.IsFalse(friendOfFriend.IsChanged);
        }
Exemple #7
0
 public void CanCancelChanges()
 {
     dynamic foo = new Person();
     var fooMixin = (IEditableObject)foo;
     fooMixin.BeginEdit();
     foo.Name = "Foo";
     foo.Boo = 1;
     fooMixin.CancelEdit();
     Assert.AreEqual(null, foo.Name);
     Assert.AreEqual(null, foo.Boo);
     fooMixin.BeginEdit();
     foo.Name = "Foo2";
     foo.Boo = 2;
     fooMixin.CancelEdit();
     Assert.AreEqual(null, foo.Name);
     Assert.AreEqual(null, foo.Boo);
 }
Exemple #8
0
 public void Init()
 {
     person = new Person
     {
         FirstName = "Bob",
         LastName = "Minion",
         DateOfBirth = DateTime.Parse("11/11/11"),
         Friends = new List<Person>
         {
             new Person
             {
                 FirstName = "Kevin",
             },
             new Person
             {
                 FirstName = "Stuart",
             }
         }
     };
 }