Ejemplo n.º 1
0
        public void TestSaveUndoSaveRedo()
        {
            var stack = new TransactionStack(5);

            using (var manager = new DirtiableManager(stack))
            {
                var dirtiable = new SimpleDirtiable();
                var operation = new SimpleDirtyingOperation(dirtiable.Yield());
                using (stack.CreateTransaction())
                {
                    stack.PushOperation(operation);
                }
                Assert.True(dirtiable.IsDirty);
                manager.CreateSnapshot();
                Assert.False(dirtiable.IsDirty);
                stack.Rollback();
                Assert.True(dirtiable.IsDirty);
                manager.CreateSnapshot();
                Assert.False(dirtiable.IsDirty);
                stack.Rollforward();
                Assert.True(dirtiable.IsDirty);
                manager.CreateSnapshot();
                Assert.False(dirtiable.IsDirty);
            }
        }
Ejemplo n.º 2
0
        public void TestDoAction()
        {
            var stack = new TransactionStack(5);

            using (new DirtiableManager(stack))
            {
                var dirtiable = new SimpleDirtiable();
                using (stack.CreateTransaction())
                {
                    var operation = new SimpleDirtyingOperation(dirtiable.Yield());
                    stack.PushOperation(operation);
                }
                Assert.True(dirtiable.IsDirty);
            }
        }
Ejemplo n.º 3
0
        public void TestUndo()
        {
            var stack = new TransactionStack(5);

            using (new DirtiableManager(stack))
            {
                var dirtiable = new SimpleDirtiable();
                var operation = new SimpleDirtyingOperation(dirtiable.Yield());
                using (stack.CreateTransaction())
                {
                    stack.PushOperation(operation);
                }
                Assert.Equal(true, dirtiable.IsDirty);
                stack.Rollback();
                Assert.Equal(false, dirtiable.IsDirty);
            }
        }
Ejemplo n.º 4
0
        public void TestDoAndSave()
        {
            var stack = new TransactionStack(5);

            using (var manager = new DirtiableManager(stack))
            {
                var dirtiable = new SimpleDirtiable();
                var operation = new SimpleDirtyingOperation(dirtiable.Yield());
                using (stack.CreateTransaction())
                {
                    stack.PushOperation(operation);
                }
                Assert.Equal(true, dirtiable.IsDirty);
                manager.CreateSnapshot();
                Assert.Equal(false, dirtiable.IsDirty);
            }
        }