Exemplo n.º 1
0
        public void TestMultipleOperationsTransactionRollforward()
        {
            var stack   = TransactionStackFactory.Create(5);
            var counter = new OrderedOperation.Counter();

            OrderedOperation[] operations = new OrderedOperation[4];
            using (stack.CreateTransaction())
            {
                for (var i = 0; i < operations.Length; ++i)
                {
                    operations[i] = new OrderedOperation(counter, i, operations.Length);
                    stack.PushOperation(operations[i]);
                }
            }
            stack.Rollback();
            // Above code must be similar to TestMultipleOperationsTransactionRollback
            counter.Reset();
            stack.Rollforward();
            Assert.False(stack.IsEmpty);
            Assert.True(stack.CanRollback);
            Assert.False(stack.CanRollforward);
            Assert.Equal(operations.Length, counter.Value);
            foreach (var operation in operations)
            {
                Assert.True(operation.IsDone);
                Assert.Equal(1, operation.RollbackCount);
                Assert.Equal(1, operation.RollforwardCount);
            }
        }
Exemplo n.º 2
0
        public void TestMultipleOperationsTransaction()
        {
            var stack   = TransactionStackFactory.Create(5);
            var counter = new OrderedOperation.Counter();

            OrderedOperation[] operations = new OrderedOperation[4];
            using (stack.CreateTransaction())
            {
                for (int i = 0; i < operations.Length; ++i)
                {
                    var operation = new OrderedOperation(counter, 0, operations.Length - i - 1);
                    stack.PushOperation(operation);
                }
            }
            Assert.False(stack.IsEmpty);
            Assert.True(stack.CanRollback);
            Assert.False(stack.CanRollforward);
        }