public void IUnDoTransactionDispose_Should_throw_When_not_the_latest_transaction() { IUnDoManager manager = new UnDoManager(1); IUnDoTransaction transaction1 = manager.BeginTransaction(); IUnDoTransaction transaction2 = manager.BeginTransaction(); Check.ThatCode(transaction1.Dispose).Throws <InvalidOperationException>(); }
public void IUnDoTransactionCommit_Should_throw_When_already_committed() { IUnDoManager manager = new UnDoManager(1); IUnDoTransaction transaction = manager.BeginTransaction(); transaction.Commit(); Check.ThatCode(transaction.Commit).Throws <InvalidOperationException>(); }
public void IUnDoTransactionCommit_Should_throw_When_already_disposed() { IUnDoManager manager = new UnDoManager(1); IUnDoTransaction transaction = manager.BeginTransaction(); transaction.Dispose(); Check.ThatCode(transaction.Commit).Throws <ObjectDisposedException>(); }
public void IUnDoTransactionDispose_Should_undo_When_not_committed() { IUnDoManager manager = new UnDoManager(1); bool unDone = false; using (IUnDoTransaction transaction = manager.BeginTransaction()) { IUnDo undo = Substitute.For <IUnDo>(); undo.When(u => u.Undo()).Do(_ => unDone = true); manager.Do(undo); } Check.That(unDone).IsTrue(); }