public void DefinitionInvalidPropagationState() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Mandatory; _mockTxnMgr.GetTransaction(def); }
public void DefinitionInvalidPropagationState() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Mandatory; Assert.Throws <IllegalTransactionStateException>(() => _mockTxnMgr.GetTransaction(def), "Transaction propagation 'mandatory' but no existing transaction found"); }
public void DefinitionInvalidTimeoutException() { MockTxnDefinition def = new MockTxnDefinition(); def.TransactionTimeout = -1000; Assert.Throws <InvalidTimeoutException>(() => _mockTxnMgr.GetTransaction(def), "Invalid transaction timeout"); }
public void NeverPropagateState() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Never; setGeneralGetTransactionExpectations(); _mockTxnMgr.GetTransaction(def); }
public void NoNestedTransactionsAllowed() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Nested; setGeneralGetTransactionExpectations(); _mockTxnMgr.GetTransaction(def); }
public void DefinitionInvalidTimeoutException() { MockTxnDefinition def = new MockTxnDefinition(); def.TransactionTimeout = -1000; _mockTxnMgr.GetTransaction(def); }
public void NoNestedTransactionsAllowed() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Nested; SetGeneralGetTransactionExpectations(); Assert.Throws<NestedTransactionNotSupportedException>(() => _mockTxnMgr.GetTransaction(def), "Transaction manager does not allow nested transactions by default - specify 'NestedTransactionsAllowed' property with value 'true'"); }
public void NeverPropagateState() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Never; SetGeneralGetTransactionExpectations(); Assert.Throws<IllegalTransactionStateException>(() => _mockTxnMgr.GetTransaction(def), "Transaction propagation 'never' but existing transaction found."); }
public void NeverPropagateState() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Never; SetGeneralGetTransactionExpectations(); Assert.Throws <IllegalTransactionStateException>(() => _mockTxnMgr.GetTransaction(def), "Transaction propagation 'never' but existing transaction found."); }
public void NoNestedTransactionsAllowed() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Nested; SetGeneralGetTransactionExpectations(); Assert.Throws <NestedTransactionNotSupportedException>(() => _mockTxnMgr.GetTransaction(def), "Transaction manager does not allow nested transactions by default - specify 'NestedTransactionsAllowed' property with value 'true'"); }
public void TransactionSuspendedSuccessfully() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.NotSupported; def.ReadOnly = false; setGeneralGetTransactionExpectations(); DefaultTransactionStatus status = (DefaultTransactionStatus)_mockTxnMgr.GetTransaction(def); Assert.IsNull(status.Transaction); Assert.IsTrue(!status.IsNewTransaction); Assert.IsTrue(status.NewSynchronization); Assert.IsTrue(!status.ReadOnly); Assert.IsNotNull(status.SuspendedResources); }
public void DefaultPropagationBehavior() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Required; def.ReadOnly = true; setGeneralGetTransactionExpectations(); DefaultTransactionStatus status = (DefaultTransactionStatus)_mockTxnMgr.GetTransaction(def); Assert.AreEqual(_mockTxnMgr.Transaction, status.Transaction); Assert.IsTrue(!status.IsNewTransaction); Assert.IsTrue(status.NewSynchronization); Assert.IsTrue(status.ReadOnly); Assert.IsNull(status.SuspendedResources); }
public void DefaultBehaviorDefaultPropagationNoExistingTransaction() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Never; def.ReadOnly = true; DefaultTransactionStatus status = (DefaultTransactionStatus)_mockTxnMgr.GetTransaction(def); Assert.IsNull(status.Transaction); Assert.IsTrue(!status.IsNewTransaction); Assert.IsTrue(status.NewSynchronization); Assert.IsTrue(status.ReadOnly); Assert.IsNull(status.SuspendedResources); Assert.AreEqual(0, _mockTxnMgr.DoBeginCallCount); AssertVanillaGetTransactionExpectations(); }
public void TransactionCreatedSuccessfully() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.RequiresNew; def.ReadOnly = false; SetGeneralGetTransactionExpectations(); DefaultTransactionStatus status = (DefaultTransactionStatus)_mockTxnMgr.GetTransaction(def); Assert.AreEqual(_mockTxnMgr.Transaction, status.Transaction); Assert.IsTrue(status.IsNewTransaction); Assert.IsTrue(status.NewSynchronization); Assert.IsTrue(!status.ReadOnly); Assert.IsNotNull(status.SuspendedResources); AssertVanillaGetTransactionExpectations(); }
public void NestedTransactionWithSavepoint() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Nested; def.ReadOnly = false; setVanillaGetTransactionExpectations(); _mockTxnMgr.SetTransaction(new MyMockTxnObjectSavepointMgr()); _mockTxnMgr.SetExpectedCalls("DoBegin", 0); _mockTxnMgr.Savepoints = true; _mockTxnMgr.NestedTransactionsAllowed = true; DefaultTransactionStatus status = (DefaultTransactionStatus)_mockTxnMgr.GetTransaction(def); Assert.AreEqual(_mockTxnMgr.Transaction, status.Transaction); Assert.IsFalse(status.IsNewTransaction); Assert.IsFalse(status.NewSynchronization); Assert.IsTrue(!status.ReadOnly); Assert.IsNull(status.SuspendedResources); }
public void NestedTransactionSuccessfully() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Nested; def.ReadOnly = false; setGeneralGetTransactionExpectations(); _mockTxnMgr.SetExpectedCalls("DoBegin", 1); _mockTxnMgr.Savepoints = false; _mockTxnMgr.NestedTransactionsAllowed = true; DefaultTransactionStatus status = (DefaultTransactionStatus)_mockTxnMgr.GetTransaction(def); Assert.AreEqual(_mockTxnMgr.Transaction, status.Transaction); Assert.IsTrue(status.IsNewTransaction); Assert.AreEqual(true, status.NewSynchronization); Assert.IsTrue(!status.ReadOnly); Assert.IsNull(status.SuspendedResources); }
public void NestedTransactionWithSavepoint() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Nested; def.ReadOnly = false; ISavepointManager saveMgr = MockRepository.GenerateMock <ISavepointManager>(); _mockTxnMgr.SetTransaction(saveMgr); _mockTxnMgr.Savepoints = true; _mockTxnMgr.NestedTransactionsAllowed = true; DefaultTransactionStatus status = (DefaultTransactionStatus)_mockTxnMgr.GetTransaction(def); Assert.AreEqual(_mockTxnMgr.Transaction, status.Transaction); Assert.IsFalse(status.IsNewTransaction); Assert.IsFalse(status.NewSynchronization); Assert.IsTrue(!status.ReadOnly); Assert.IsNull(status.SuspendedResources); AssertVanillaGetTransactionExpectations(); Assert.AreEqual(0, _mockTxnMgr.DoBeginCallCount); }
public void DefinitionInvalidTimeoutException() { MockTxnDefinition def = new MockTxnDefinition(); def.TransactionTimeout = -1000; Assert.Throws<InvalidTimeoutException>(() => _mockTxnMgr.GetTransaction(def), "Invalid transaction timeout"); }
public void DefinitionInvalidPropagationState() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Mandatory; Assert.Throws<IllegalTransactionStateException>(() => _mockTxnMgr.GetTransaction(def), "Transaction propagation 'mandatory' but no existing transaction found"); }
public void NestedTransactionSuccessfully() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Nested; def.ReadOnly = false; SetGeneralGetTransactionExpectations(); _mockTxnMgr.Savepoints = false; _mockTxnMgr.NestedTransactionsAllowed = true; DefaultTransactionStatus status = (DefaultTransactionStatus) _mockTxnMgr.GetTransaction(def); Assert.AreEqual(_mockTxnMgr.Transaction, status.Transaction); Assert.IsTrue(status.IsNewTransaction); Assert.AreEqual(true, status.NewSynchronization); Assert.IsTrue(!status.ReadOnly); Assert.IsNull(status.SuspendedResources); AssertVanillaGetTransactionExpectations(); Assert.AreEqual(1, _mockTxnMgr.DoBeginCallCount); }
public void NestedTransactionWithSavepoint() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Nested; def.ReadOnly = false; ISavepointManager saveMgr = MockRepository.GenerateMock<ISavepointManager>(); _mockTxnMgr.SetTransaction(saveMgr); _mockTxnMgr.Savepoints = true; _mockTxnMgr.NestedTransactionsAllowed = true; DefaultTransactionStatus status = (DefaultTransactionStatus) _mockTxnMgr.GetTransaction(def); Assert.AreEqual(_mockTxnMgr.Transaction, status.Transaction); Assert.IsFalse(status.IsNewTransaction); Assert.IsFalse(status.NewSynchronization); Assert.IsTrue(!status.ReadOnly); Assert.IsNull(status.SuspendedResources); AssertVanillaGetTransactionExpectations(); Assert.AreEqual(0, _mockTxnMgr.DoBeginCallCount); }
public void DefaultPropagationBehavior() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Required; def.ReadOnly = true; SetGeneralGetTransactionExpectations(); DefaultTransactionStatus status = (DefaultTransactionStatus) _mockTxnMgr.GetTransaction(def); Assert.AreEqual(_mockTxnMgr.Transaction, status.Transaction); Assert.IsTrue(!status.IsNewTransaction); Assert.IsTrue(status.NewSynchronization); Assert.IsTrue(status.ReadOnly); Assert.IsNull(status.SuspendedResources); AssertVanillaGetTransactionExpectations(); }
public void DefaultBehaviorDefaultPropagationNoExistingTransaction() { MockTxnDefinition def = new MockTxnDefinition(); def.PropagationBehavior = TransactionPropagation.Never; def.ReadOnly = true; DefaultTransactionStatus status = (DefaultTransactionStatus) _mockTxnMgr.GetTransaction(def); Assert.IsNull(status.Transaction); Assert.IsTrue(!status.IsNewTransaction); Assert.IsTrue(status.NewSynchronization); Assert.IsTrue(status.ReadOnly); Assert.IsNull(status.SuspendedResources); Assert.AreEqual(0, _mockTxnMgr.DoBeginCallCount); AssertVanillaGetTransactionExpectations(); }