public void service_on_clear_undo_entities_are_restored() { var source = new Person[] { new Person(null, false), new Person(null, false), new Person(null, false), new Person(null, false), new Person(null, false) }; ChangeTrackingService svc = new ChangeTrackingService(); PersonCollection list = new PersonCollection(svc); list.BeginInit(); list.AddRange(source); list.EndInit(); list.Clear(); svc.Undo(); Assert.AreEqual <int>(source.Length, list.Count()); source.ForEach(p => { int expected = Array.IndexOf(source, p); int actual = list.IndexOf(p); Assert.AreEqual <int>(expected, actual); }); }
public void service_on_clear_generate_valid_advisory() { ChangeTrackingService svc = new ChangeTrackingService(); PersonCollection p = new PersonCollection(svc); p.Add(new Person(null, false)); p.Add(new Person(null, false)); p.Add(new Person(null, false)); p.Add(new Person(null, false)); p.Add(new Person(null, false)); svc.AcceptChanges(); p.Clear(); IEnumerable <IAdvisedAction> advisory = svc.GetAdvisory(); Assert.IsNotNull(advisory); Assert.AreEqual <int>(5, advisory.Count()); foreach (var aa in advisory) { Assert.AreEqual <ProposedActions>(ProposedActions.Delete, aa.Action); } }