Пример #1
0
        public void RegisterInvokation_InvokationNullReference_ThrowsException()
        {
            TransactionManagerStub transactionManager = new TransactionManagerStub();
            Transaction            target             = new Transaction(transactionManager);

            Assert.Throws <ArgumentNullException>(() => target.RegisterInvokation((IInvokable)null));
        }
Пример #2
0
        public void Rollback_RollbacksTransactionInTransactionManager()
        {
            TransactionManagerStub transactionManager = new TransactionManagerStub();
            Transaction            target             = new Transaction(transactionManager);

            target.Rollback();

            Assert.True(transactionManager.RollbackCalled);
        }
Пример #3
0
        public void Commit_CommitsTransactionInTransactionManager()
        {
            TransactionManagerStub transactionManager = new TransactionManagerStub();
            Transaction            target             = new Transaction(transactionManager);

            target.Commit();

            Assert.True(transactionManager.CommitCalled);
        }
Пример #4
0
        public void Dispose_CommitsTransaction()
        {
            TransactionManagerStub transactionManager = new TransactionManagerStub();
            Transaction            target             = new Transaction(transactionManager);

            target.Dispose();

            Assert.True(transactionManager.CommitCalled);
        }
Пример #5
0
        public void SetActionName_StringNullReference_SetsEmptyString()
        {
            TransactionManagerStub transactionManager = new TransactionManagerStub();
            Transaction            target             = new Transaction(transactionManager);

            target.ActionName = null;

            string expected = string.Empty;
            string actual   = target.ActionName;

            Assert.Equal(expected, actual);
        }
Пример #6
0
        public void SetActionName_ValidActionName_SetsEmptyString()
        {
            TransactionManagerStub transactionManager = new TransactionManagerStub();
            Transaction            target             = new Transaction(transactionManager);

            string expected = "Paste";

            target.ActionName = expected;

            string actual = target.ActionName;

            Assert.Equal(expected, actual);
        }
Пример #7
0
        public void RegisterInvokation_AddsInvokationToTheInternalStack()
        {
            TransactionManagerStub transactionManager = new TransactionManagerStub();
            Transaction            target             = new Transaction(transactionManager);

            Mock <IInvokable> invokableMock = new Mock <IInvokable>(MockBehavior.Loose);

            target.RegisterInvokation(invokableMock.Object);

            target.Invoke();

            invokableMock.Verify(i => i.Invoke(), Times.Once());
        }
Пример #8
0
        public void Invoke_InvokesAllRegisteredInvokations()
        {
            TransactionManagerStub transactionManager = new TransactionManagerStub();
            Transaction            target             = new Transaction(transactionManager);

            Mock <IInvokable> invokableMock1 = new Mock <IInvokable>(MockBehavior.Loose);
            Mock <IInvokable> invokableMock2 = new Mock <IInvokable>(MockBehavior.Loose);

            invokableMock1.Setup(i => i.Invoke()).Callback(() => invokableMock2.Verify(t => t.Invoke(), Times.Once()));
            invokableMock2.Setup(i => i.Invoke()).Callback(() => invokableMock1.Verify(t => t.Invoke(), Times.Never()));

            target.RegisterInvokation(invokableMock1.Object);
            target.RegisterInvokation(invokableMock2.Object);

            target.Invoke();

            invokableMock1.Verify(i => i.Invoke(), Times.Once());
            invokableMock2.Verify(i => i.Invoke(), Times.Once());
        }