Ejemplo n.º 1
0
        public void service_redoes_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);

            while (svc.CanUndo)
            {
                svc.Undo();
            }

            svc.Redo();
            Assert.AreEqual <int>(1, list.Count);
            Assert.IsTrue(list.Contains(p1));

            svc.Redo();
            Assert.AreEqual <int>(2, list.Count);
            Assert.IsTrue(list.Contains(p2));

            svc.Redo();
            Assert.AreEqual <int>(3, list.Count);
            Assert.IsTrue(list.Contains(p3));

            svc.Redo();
            Assert.AreEqual <int>(0, list.IndexOf(p2));

            svc.Redo();
            Assert.AreEqual <int>(2, list.Count);
            Assert.IsFalse(list.Contains(p1));
        }
Ejemplo n.º 2
0
        public void afterUndo_service_Redo_restore_previous_value()
        {
            ChangeTrackingService svc = new ChangeTrackingService();
            int expected = 1;

            PersonCollection p = new PersonCollection(svc);

            p.Add(new Person(null, false));

            svc.Undo();
            svc.Redo();

            Assert.AreEqual <int>(expected, p.Count);
        }
Ejemplo n.º 3
0
        public void mementoEntity_using_trackingService_should_undo_and_redo_a_single_change()
        {
            var expected = "Mauro";

            var memento = new ChangeTrackingService();

            var target = new MementoMockEntity();

            ((IMemento)target).Memento = memento;

            target.FirstName = expected;

            memento.Undo();
            memento.Redo();

            target.FirstName.Should().Be.EqualTo(expected);
        }
Ejemplo n.º 4
0
        public void changeTrackingService_using_beginAtomicOperation_redo_should_reapply_all_changes_with_one_pass()
        {
            var target = new ChangeTrackingService();

            var person = new Person(target);
            var list   = new PersonCollection(target);

            using (var actual = target.BeginAtomicOperation())
            {
                person.Name = "Mauro";
                list.Add(person);
                person.Name = "Mauro Servienti";

                actual.Complete();
            }

            target.Undo();
            target.Redo();

            list.Count.Should().Be.EqualTo(1);
            person.Name.Should().Be.EqualTo("Mauro Servienti");
        }