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.Equal(false, stack.IsEmpty); Assert.Equal(true, stack.CanRollback); Assert.Equal(false, stack.CanRollforward); Assert.Equal(operations.Length, counter.Value); foreach (var operation in operations) { Assert.Equal(true, operation.IsDone); Assert.Equal(1, operation.RollbackCount); Assert.Equal(1, operation.RollforwardCount); } }
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.Equal(false, stack.IsEmpty); Assert.Equal(true, stack.CanRollback); Assert.Equal(false, stack.CanRollforward); }