本文整理汇总了C#中MonoTests.System.Transactions.IntResourceManager类的典型用法代码示例。如果您正苦于以下问题:C# IntResourceManager类的具体用法?C# IntResourceManager怎么用?C# IntResourceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntResourceManager类属于MonoTests.System.Transactions命名空间,在下文中一共展示了IntResourceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Vol1_Dur0_2PC
public void Vol1_Dur0_2PC ()
{
IntResourceManager irm = new IntResourceManager (1);
using (TransactionScope scope = new TransactionScope ()) {
irm.Value = 2;
scope.Complete ();
}
irm.Check2PC ("irm");
}
示例2: Vol1_Dur0_Fail3
public void Vol1_Dur0_Fail3 ()
{
IntResourceManager irm = new IntResourceManager (1);
irm.UseSingle = true;
irm.FailSPC = true;
using (TransactionScope scope = new TransactionScope ()) {
irm.Value = 2;
scope.Complete ();
}
}
示例3: Vol1_Dur0_Fail1
public void Vol1_Dur0_Fail1 ()
{
IntResourceManager irm = new IntResourceManager (1);
irm.UseSingle = true;
using (TransactionScope scope = new TransactionScope ()) {
irm.Value = 2;
/* Not completing this..
scope.Complete ();*/
}
irm.Check ( 0, 0, 0, 1, 0, 0, 0, "irm" );
}
示例4: AsyncFail1
public void AsyncFail1 ()
{
IntResourceManager irm = new IntResourceManager ( 1 );
CommittableTransaction ct = new CommittableTransaction ();
/* Set ambient Tx */
Transaction.Current = ct;
/* Enlist */
irm.Value = 2;
IAsyncResult ar = ct.BeginCommit ( null, null );
IAsyncResult ar2 = ct.BeginCommit ( null, null );
}
示例5: TransactionScopeAbort
public void TransactionScopeAbort ()
{
Assert.IsNull (Transaction.Current, "Ambient transaction exists");
IntResourceManager irm = new IntResourceManager (1);
using (TransactionScope scope = new TransactionScope ()) {
Assert.IsNotNull (Transaction.Current, "Ambient transaction does not exist");
Assert.AreEqual (TransactionStatus.Active, Transaction.Current.TransactionInformation.Status, "transaction is not active");
irm.Value = 2;
/* Not completing scope here */
}
irm.Check ( 0, 0, 1, 0, "irm");
Assert.AreEqual (1, irm.Value);
Assert.IsNull (Transaction.Current, "Ambient transaction exists");
}
示例6: AsyncFail2
public void AsyncFail2 ()
{
IntResourceManager irm = new IntResourceManager ( 1 );
CommittableTransaction ct = new CommittableTransaction ();
/* Set ambient Tx */
Transaction.Current = ct;
/* Enlist */
irm.Value = 2;
irm.FailPrepare = true;
IAsyncResult ar = ct.BeginCommit ( null, null );
ct.EndCommit ( ar );
}
示例7: NestedTransactionScope1
public void NestedTransactionScope1 ()
{
IntResourceManager irm = new IntResourceManager (1);
Assert.IsNull (Transaction.Current, "Ambient transaction exists");
using (TransactionScope scope = new TransactionScope ()) {
irm.Value = 2;
/* Complete this scope */
scope.Complete ();
}
Assert.IsNull (Transaction.Current, "Ambient transaction exists");
/* Value = 2, got committed */
Assert.AreEqual (irm.Value, 2, "#1");
irm.Check ( 1, 1, 0, 0, "irm" );
}
示例8: Vol1_Dur0_Fail2
public void Vol1_Dur0_Fail2 ()
{
ExceptionAssert.Throws<TransactionAbortedException>(
delegate
{
IntResourceManager irm = new IntResourceManager(1);
irm.FailPrepare = true;
using (TransactionScope scope = new TransactionScope())
{
irm.Value = 2;
scope.Complete();
}
});
}
示例9: AsyncFail1
public void AsyncFail1 ()
{
ExceptionAssert.Throws<InvalidOperationException>(
delegate
{
IntResourceManager irm = new IntResourceManager(1);
CommittableTransaction ct = new CommittableTransaction();
/* Set ambient Tx */
Transaction.Current = ct;
/* Enlist */
irm.Value = 2;
IAsyncResult ar = ct.BeginCommit(null, null);
IAsyncResult ar2 = ct.BeginCommit(null, null);
});
}
示例10: Vol2_Dur1_Fail3
public void Vol2_Dur1_Fail3 ()
{
IntResourceManager [] irm = new IntResourceManager [4];
irm [0] = new IntResourceManager ( 1 );
irm [1] = new IntResourceManager ( 3 );
irm [2] = new IntResourceManager ( 5 );
irm [3] = new IntResourceManager ( 7 );
irm [0].Type = ResourceManagerType.Durable;
irm [2].FailPrepare = true;
for ( int i = 0; i < 4; i++ )
irm [i].UseSingle = true;
/* Durable RM irm[2] does on SPC, so
* all volatile RMs get Rollback */
try {
using (TransactionScope scope = new TransactionScope ()) {
irm [0].Value = 2;
irm [1].Value = 6;
irm [2].Value = 10;
irm [3].Value = 14;
scope.Complete ();
}
}
catch (TransactionAbortedException) {
irm [0].Check ( 0, 0, 0, 1, 0, 0, 0, "irm [0]");
/* irm [1] & [2] get prepare,
* [2] -> ForceRollback,
* [1] & [3] get rollback,
* [0](durable) gets rollback */
irm [1].Check ( 0, 1, 0, 1, 0, 0, 0, "irm [1]" );
irm [2].Check ( 0, 1, 0, 0, 0, 0, 0, "irm [2]" );
irm [3].Check ( 0, 0, 0, 1, 0, 0, 0, "irm [3]" );
return;
}
Assert.Fail ( "Expected TransactionAbortedException" );
}
示例11: Vol2_Dur1_Fail2b
public void Vol2_Dur1_Fail2b()
{
TransactionAbortedException exception = null;
IntResourceManager[] irm = new IntResourceManager[4];
irm[0] = new IntResourceManager(1);
irm[1] = new IntResourceManager(3);
irm[2] = new IntResourceManager(5);
irm[3] = new IntResourceManager(7);
irm[0].IgnoreSPC = true;
irm[1].Type = ResourceManagerType.Durable;
for (int i = 0; i < 4; i++)
irm[i].UseSingle = true;
/* Durable RM irm[2] does on SPC, so
* all volatile RMs get Rollback */
try
{
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(0, 0, 5)))
{
irm[0].Value = 2;
irm[1].Value = 6;
irm[2].Value = 10;
irm[3].Value = 14;
scope.Complete();
}
}
catch (TransactionAbortedException ex)
{
irm[0].CheckSPC("irm [0]");
/* Volatile RMs get 2PC Prepare, and then get rolled back */
for (int i = 1; i < 4; i++)
irm[i].Check(0, 1, 0, 1, 0, 0, 0, "irm [" + i + "]");
exception = ex;
}
Assert.IsNotNull(exception, "Expected TransactionAbortedException not thrown!");
Assert.IsNotNull(exception.InnerException, "TransactionAbortedException has no inner exception!");
Assert.AreEqual(typeof(TimeoutException), exception.InnerException.GetType());
}
示例12: Vol2_Dur1_Fail1
public void Vol2_Dur1_Fail1 ()
{
IntResourceManager [] irm = new IntResourceManager [4];
irm [0] = new IntResourceManager (1);
irm [1] = new IntResourceManager (3);
irm [2] = new IntResourceManager (5);
irm [3] = new IntResourceManager (7);
irm [0].Type = ResourceManagerType.Durable;
irm [0].FailSPC = true;
for ( int i = 0; i < 4; i++ )
irm [i].UseSingle = true;
/* Durable RM irm[0] does Abort on SPC, so
* all volatile RMs get Rollback */
try {
using (TransactionScope scope = new TransactionScope ()) {
irm [0].Value = 2;
irm [1].Value = 6;
irm [2].Value = 10;
irm [3].Value = 14;
scope.Complete ();
}
}
catch (TransactionAbortedException) {
irm [0].CheckSPC ( "irm [0]" );
/* Volatile RMs get 2PC Prepare, and then get rolled back */
for (int i = 1; i < 4; i++)
irm [i].Check ( 0, 1, 0, 1, 0, 0, 0, "irm [" + i + "]" );
}
}
示例13: TransactionDispose
public void TransactionDispose ()
{
CommittableTransaction ct = new CommittableTransaction ();
IntResourceManager irm = new IntResourceManager (1);
irm.Type = ResourceManagerType.Durable;
ct.Dispose ();
irm.Check (0, 0, 0, 0, "Dispose transaction");
}
示例14: Async1
public void Async1 ()
{
IntResourceManager irm = new IntResourceManager ( 1 );
CommittableTransaction ct = new CommittableTransaction ();
/* Set ambient Tx */
Transaction.Current = ct;
/* Enlist */
irm.Value = 2;
callback = new AsyncCallback (CommitCallback);
IAsyncResult ar = ct.BeginCommit ( callback, 5);
mr.WaitOne (new TimeSpan (0, 2, 0), true);
Assert.IsTrue (called, "callback not called" );
Assert.AreEqual ( 5, state, "State not received back");
if ( delayedException != null )
throw new Exception ("", delayedException );
}
示例15: Vol0_Dur0_Pspe2
public void Vol0_Dur0_Pspe2 ()
{
IntResourceManager irm0 = new IntResourceManager (1);
IntResourceManager irm1 = new IntResourceManager (1);
irm0.Type = ResourceManagerType.Promotable;
irm1.Type = ResourceManagerType.Promotable;
using (TransactionScope scope = new TransactionScope ()) {
irm0.Value = 8;
irm1.Value = 2;
Assert.AreEqual(0, irm1.NumEnlistFailed, "PSPE enlist did not fail although PSPE RM was already enlisted");
}
}