Beispiel #1
0
        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));
        }