public void ComplexOperationShouldHandleRollbackOperationFailure()
        {
            var items = new List<int>();
            var operation = new ComplexOperation();

            operation.AddOperationAtTheEnd(GetTestingAtomicOperation(4, items, OperationResult.Success, OperationResult.Success));
            operation.AddOperationAtTheEnd(GetTestingAtomicOperation(8, items, OperationResult.Success, OperationResult.Success));
            operation.AddOperationAtTheEnd(GetTestingAtomicOperation(15, items, OperationResult.Success, OperationResult.Fail("rollback failure")));
            operation.AddOperationAtTheEnd(GetTestingAtomicOperation(16, items, OperationResult.Success, OperationResult.Success));
            operation.AddOperationAtTheEnd(GetTestingAtomicOperation(23, items, OperationResult.Success, OperationResult.Success));

            operation.Execute();
            Assert.That(items, Is.EqualTo(new[] { 4, 8, 15, 16, 23 }));

            var rollbackResult = operation.Rollback();
            Assert.That(rollbackResult.Succeeded, Is.False);
            Assert.That(rollbackResult.Message, Is.EqualTo("rollback failure"));
            Assert.That(items, Is.EqualTo(new[] { 4, 8, -15, -16, -23 }));
        }
        public void ComplexOperationShouldRollbackOperationsInReverseOrder()
        {
            var items = new List<int>();
            var operation = new ComplexOperation();

            operation.AddOperationAtTheEnd(GetTestingAtomicOperation(4, items, OperationResult.Success, OperationResult.Success));
            operation.AddOperationAtTheEnd(GetTestingAtomicOperation(8, items, OperationResult.Success, OperationResult.Success));
            operation.AddOperationAtTheEnd(GetTestingAtomicOperation(15, items, OperationResult.Success, OperationResult.Success));
            operation.AddOperationAtTheEnd(GetTestingAtomicOperation(16, items, OperationResult.Success, OperationResult.Success));
            operation.AddOperationAtTheEnd(GetTestingAtomicOperation(23, items, OperationResult.Success, OperationResult.Success));

            operation.Execute();
            Assert.That(items, Is.EqualTo(new[] {4, 8, 15, 16, 23}));

            operation.Rollback();
            Assert.That(items, Is.EqualTo(new[] { -4, -8, -15, -16, -23 }));
        }