Example #1
0
        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>();
        }
Example #2
0
        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>();
        }
Example #3
0
        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>();
        }
Example #4
0
        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();
        }