本文整理汇总了C#中MonoTests.System.Transactions.IntResourceManager类的典型用法代码示例。如果您正苦于以下问题:C# IntResourceManager类的具体用法?C# IntResourceManager怎么用?C# IntResourceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntResourceManager类属于MonoTests.System.Transactions命名空间,在下文中一共展示了IntResourceManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
开发者ID:HarrievG,项目名称:mono,代码行数:11,代码来源:EnlistTest.cs
示例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 ();
}
}
开发者ID:HarrievG,项目名称:mono,代码行数:12,代码来源:EnlistTest.cs
示例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" );
}
开发者ID:HarrievG,项目名称:mono,代码行数:13,代码来源:EnlistTest.cs
示例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 );
}
开发者ID:nlhepler,项目名称:mono,代码行数:14,代码来源:AsyncTest.cs
示例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");
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:15,代码来源:TransactionScopeTest.cs
示例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 );
}
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:AsyncTest.cs
示例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" );
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:17,代码来源:TransactionScopeTest.cs
示例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();
}
});
}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:17,代码来源:EnlistTest.cs
示例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);
});
}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:18,代码来源:AsyncTest.cs
示例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" );
}
开发者ID:HarrievG,项目名称:mono,代码行数:42,代码来源:EnlistTest.cs
示例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());
}
开发者ID:HarrievG,项目名称:mono,代码行数:44,代码来源:EnlistTest.cs
示例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 + "]" );
}
}
开发者ID:HarrievG,项目名称:mono,代码行数:33,代码来源:EnlistTest.cs
示例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");
}
开发者ID:HarrievG,项目名称:mono,代码行数:9,代码来源:EnlistTest.cs
示例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 );
}
开发者ID:nlhepler,项目名称:mono,代码行数:20,代码来源:AsyncTest.cs
示例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");
}
}
开发者ID:HarrievG,项目名称:mono,代码行数:12,代码来源:EnlistTest.cs
示例16: Vol2_Dur1_Fail4
public void Vol2_Dur1_Fail4 ()
{
IntResourceManager [] irm = new IntResourceManager [2];
irm [0] = new IntResourceManager ( 1 );
irm [1] = new IntResourceManager ( 3 );
irm [0].Type = ResourceManagerType.Durable;
irm [0].FailSPC = true;
irm [0].FailWithException = true;
for ( int i = 0; i < 2; 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;
scope.Complete ();
}
}
catch ( TransactionAbortedException e) {
Assert.IsNotNull ( e.InnerException, "Expected e.InnerException == NotSupportedException, but got None");
Assert.AreEqual ( typeof ( NotSupportedException ), e.InnerException.GetType (), "Expected e.InnerException == NotSupportedException, but got " + e.GetType () );
irm [0].Check ( 1, 0, 0, 0, 0, 0, 0, "irm [0]" );
irm [1].Check ( 0, 1, 0, 1, 0, 0, 0, "irm [1]" );
return;
}
Assert.Fail ( "Expected TransactionAbortedException" );
}
开发者ID:HarrievG,项目名称:mono,代码行数:34,代码来源:EnlistTest.cs
示例17: Async2
public void Async2 ()
{
IntResourceManager irm = new IntResourceManager ( 1 );
CommittableTransaction ct = new CommittableTransaction ();
using ( TransactionScope scope = new TransactionScope (ct) ) {
irm.Value = 2;
//scope.Complete ();
IAsyncResult ar = ct.BeginCommit ( null, null);
try {
ct.EndCommit ( ar );
}
catch ( TransactionAbortedException) {
irm.Check ( 0, 0, 1, 0, "irm" );
return;
}
}
Assert.Fail ( "EndCommit should've thrown an exception" );
}
开发者ID:nlhepler,项目名称:mono,代码行数:22,代码来源:AsyncTest.cs
示例18: Async5
public void Async5 ()
{
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 );
ar.AsyncWaitHandle.WaitOne ();
Assert.IsTrue ( ar.IsCompleted );
try {
CommittableTransaction ctx = ar as CommittableTransaction;
ctx.EndCommit ( ar );
} catch ( TransactionAbortedException ) {
irm.Check ( 1, 0, 0, 0, "irm" );
return;
}
Assert.Fail ("EndCommit should've failed");
}
开发者ID:nlhepler,项目名称:mono,代码行数:25,代码来源:AsyncTest.cs
示例19: Async4
public void Async4 ()
{
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 );
ar.AsyncWaitHandle.WaitOne ();
Assert.IsTrue ( ar.IsCompleted );
irm.Check ( 1, 1, 0, 0, "irm" );
}
开发者ID:nlhepler,项目名称:mono,代码行数:17,代码来源:AsyncTest.cs
示例20: Async3
public void Async3 ()
{
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 );
ct.EndCommit ( ar );
irm.Check ( 1, 1, 0, 0, "irm" );
}
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:AsyncTest.cs
注:本文中的MonoTests.System.Transactions.IntResourceManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论