Пример #1
0
        public void TrackInnerArray_With_Null()
        {
            var item = new MyTrackedItemWithArray {
                MyItems = new string[4]
            };

            item.MyItems[0] = "A";
            item.MyItems[1] = "B";

            var tracker = new ChangeTracker();

            tracker.TrackChanges(item);
            Assert.IsFalse(tracker.CheckChanges());

            //// "redimensionnement" du tableau
            //string[] newItems = new string[4];
            //Array.Copy(item.MyItems, newItems, 2);
            //item.MyItems = newItems;

            // change
            item.MyItems[2] = "C";
            Assert.IsTrue(tracker.CheckChanges());

            // back
            item.MyItems[2] = null;
            Assert.IsFalse(tracker.CheckChanges());
        }
Пример #2
0
        public void TrackInnerArray_That_Value_Changed()
        {
            var item = new MyTrackedItemWithArray {
                MyItems = new string[] { "A", "B" }
            };

            var tracker = new ChangeTracker();

            tracker.TrackChanges(item);
            Assert.IsFalse(tracker.CheckChanges());

            // change
            item.MyItems[1] = "B!";
            Assert.IsTrue(tracker.CheckChanges());

            // back
            item.MyItems[1] = "B";
            Assert.IsFalse(tracker.CheckChanges());
        }