Exemplo n.º 1
0
        public void CanUndoIsTrueAfterCommitData()
        {
            var persister = TestsHelper.GetPersisterWithSimpleObject(15, "John");

            Assert.AreEqual(persister.CanUndo, false);

            persister.TrackedObject.Age = 5;
            persister.CommitCurrentState("1");
            Assert.AreEqual(true, persister.CanUndo);
        }
Exemplo n.º 2
0
        public void CanUndoChangedEventIsFiredWhenDataAreCommited()
        {
            var persister = TestsHelper.GetPersisterWithSimpleObject(15, "John");

            var numberOfEventFires = 0;

            persister.CanUndoChanged += (e, o) =>
            {
                numberOfEventFires++;
            };

            persister.CommitCurrentState("1");

            Assert.AreEqual(1, numberOfEventFires);
        }
Exemplo n.º 3
0
        public void RedoHistoryIsDestroyedWhenCommitingInHistory()
        {
            var persister = TestsHelper.GetPersisterWithSimpleObject(15, "John");

            persister.TrackedObject.Age = 1;
            persister.CommitCurrentState("1");
            persister.Undo();

            Assert.AreEqual(persister.CanRedo, true);

            persister.TrackedObject.Age = 2;
            persister.CommitCurrentState("2");

            Assert.AreEqual(false, persister.CanRedo);
        }
Exemplo n.º 4
0
        public void CanReturnToPreviousStateWithUndo()
        {
            var persister = TestsHelper.GetPersisterWithSimpleObject(15, "John");

            // commit current state before change
            persister.CommitCurrentState("1");

            persister.TrackedObject.Age  = 16;
            persister.TrackedObject.Name = "Jack";

            var historyId = persister.Undo();

            Assert.AreEqual("1", historyId);
            Assert.AreEqual(15, persister.TrackedObject.Age);
            Assert.AreEqual("John", persister.TrackedObject.Name);
        }
Exemplo n.º 5
0
        public void CanRedoEventIsFiredWhenRedoBecameAvailable()
        {
            var persister = TestsHelper.GetPersisterWithSimpleObject(15, "John");

            var numberOfEventFires = 0;

            persister.CanRedoChanged += (e, o) =>
            {
                numberOfEventFires++;
            };

            persister.CommitCurrentState("1");
            persister.Undo();

            Assert.AreEqual(1, numberOfEventFires);
        }
Exemplo n.º 6
0
        public void CanUndoChangedEventIsFiredTwiceWhenUndoIsAvailableAndLaterUnavailable()
        {
            var persister = TestsHelper.GetPersisterWithSimpleObject(15, "John");

            var numberOfEventFires = 0;

            persister.CanUndoChanged += (e, o) =>
            {
                numberOfEventFires++;
            };

            persister.CommitCurrentState("1");
            persister.Undo();

            Assert.AreEqual(2, numberOfEventFires);
        }
        public void PropertyChangedIsRisenOnUndoOperation()
        {
            var persister = TestsHelper.GetPersisterWithSimpleObject(15, "John");

            persister.CommitCurrentState("1");

            persister.TrackedObject.Age = 5;
            int propertyChangedCount = 0;

            persister.TrackedObject.PropertyChanged += (e, v) =>
            {
                propertyChangedCount++;
            };

            persister.Undo();

            Assert.AreEqual(1, propertyChangedCount);
        }
Exemplo n.º 8
0
        public void CanRedoToTheLatestStateAfterUndo()
        {
            var persister = TestsHelper.GetPersisterWithSimpleObject(15, "John");

            // commit current state before change
            persister.CommitCurrentState("1");

            persister.TrackedObject.Age  = 16;
            persister.TrackedObject.Name = "Jack";

            var historyId = persister.Undo();

            historyId = persister.Redo();

            Assert.IsTrue(string.IsNullOrEmpty(historyId));
            Assert.AreEqual(16, persister.TrackedObject.Age);
            Assert.AreEqual("Jack", persister.TrackedObject.Name);
        }