Ejemplo n.º 1
0
        public void ChangeTracking_EntitySubCollectionTracking()
        {
            var wh = new WorkHistory {
                Name = "Avanade"
            };
            var pd = new PersonDetail {
                History = new WorkHistoryCollection {
                    wh
                }
            };

            pd.AcceptChanges();
            Assert.IsFalse(pd.IsChanged);
            Assert.IsFalse(pd.History.IsChanged);
            Assert.IsFalse(wh.IsChanged);

            pd.TrackChanges();
            wh.Name = "Accenture";
            Assert.IsTrue(wh.IsChanged);
            Assert.AreEqual(new System.Collections.Specialized.StringCollection {
                "Name"
            }, wh.ChangeTracking);
            Assert.IsTrue(pd.History.IsChanged);
            Assert.IsNull(pd.History.ChangeTracking); // Collections always return null.
            Assert.IsTrue(pd.IsChanged);
            Assert.AreEqual(new System.Collections.Specialized.StringCollection {
                "History"
            }, pd.ChangeTracking);
        }