public void service_undoes_are_in_the_correct_order() { var p1 = new Person(null, false); var p2 = new Person(null, false); var p3 = new Person(null, false); ChangeTrackingService svc = new ChangeTrackingService(); PersonCollection list = new PersonCollection(svc); list.Add(p1); list.Add(p2); list.Add(p3); list.Move(p2, 0); list.Remove(p1); svc.Undo(); Assert.AreEqual <int>(3, list.Count); Assert.IsTrue(list.Contains(p1)); svc.Undo(); Assert.AreEqual <int>(1, list.IndexOf(p2)); svc.Undo(); Assert.AreEqual <int>(2, list.Count); Assert.IsFalse(list.Contains(p3)); svc.Undo(); Assert.AreEqual <int>(1, list.Count); Assert.IsFalse(list.Contains(p2)); svc.Undo(); Assert.AreEqual <int>(0, list.Count); Assert.IsFalse(list.Contains(p1)); }
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); }); }