本文整理汇总了C#中MonoTests.System.Transactions.IntResourceManager.Check方法的典型用法代码示例。如果您正苦于以下问题:C# IntResourceManager.Check方法的具体用法?C# IntResourceManager.Check怎么用?C# IntResourceManager.Check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoTests.System.Transactions.IntResourceManager
的用法示例。
在下文中一共展示了IntResourceManager.Check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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" );
}
示例2: 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");
}
示例3: RMFail1
public void RMFail1 ()
{
IntResourceManager irm = new IntResourceManager (1);
IntResourceManager irm2 = new IntResourceManager (10);
IntResourceManager irm3 = new IntResourceManager (12);
Assert.IsNull (Transaction.Current, "Ambient transaction exists (before)");
try {
using (TransactionScope scope = new TransactionScope ()) {
irm.Value = 2;
irm2.Value = 20;
irm3.Value = 24;
/* Make second RM fail to prepare, this should throw
* TransactionAbortedException when the scope ends
*/
irm2.FailPrepare = true;
scope.Complete ();
}
} catch (TransactionAbortedException) {
irm.Check ( 1, 0, 1, 0, "irm");
irm2.Check ( 1, 0, 0, 0, "irm2");
irm3.Check ( 0, 0, 1, 0, "irm3");
}
Assert.IsNull (Transaction.Current, "Ambient transaction exists (after)");
}
示例4: 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");
}
示例5: 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");
}
示例6: 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" );
}
示例7: Vol2_Rollback
public void Vol2_Rollback()
{
TransactionStatus status = TransactionStatus.Active;
bool called = false;
var rm1 = new IntResourceManager(1)
{
Type = ResourceManagerType.Volatile
};
var rm2 = new IntResourceManager(1)
{
Type = ResourceManagerType.Volatile
};
using (var ts = new TransactionScope())
{
rm1.Value = 11;
rm2.Value = 22;
var tr = Transaction.Current;
tr.TransactionCompleted += (s, e) => { called = true; status = e.Transaction.TransactionInformation.Status; };
// Not calling ts.Complete() on purpose..
}
rm1.Check(0, 0, 0, 1, 0, 0, 0, "rm1");
rm2.Check(0, 0, 0, 1, 0, 0, 0, "rm2");
Assert.IsTrue(called, "TransactionCompleted event handler not called!");
Assert.AreEqual(TransactionStatus.Aborted, status, "TransactionStatus != Aborted");
}
示例8: Vol1_Throwing_On_Prepare
public void Vol1_Throwing_On_Prepare()
{
bool called = false;
TransactionStatus status = TransactionStatus.Active;
Exception ex = null;
var rm = new IntResourceManager(1)
{
FailPrepare = true,
FailWithException = true,
Type = ResourceManagerType.Volatile
};
try
{
using (var ts = new TransactionScope())
{
rm.Value = 2;
var tr = Transaction.Current;
tr.TransactionCompleted += (s, e) => { called = true; status = e.Transaction.TransactionInformation.Status; };
ts.Complete();
}
}
catch (Exception _ex)
{
ex = _ex;
}
rm.Check(0, 1, 0, 0, 0, 0, 0, "rm");
Assert.IsTrue(called, "TransactionCompleted event handler not called!");
Assert.IsNotNull(ex, "Exception not thrown");
Assert.IsInstanceOfType(ex, typeof(TransactionAbortedException), "Invalid exception thrown");
Assert.IsNotNull(ex.InnerException, "InnerException is null");
Assert.IsInstanceOfType(ex.InnerException, typeof(NotSupportedException), "Invalid inner exception thrown");
Assert.AreEqual(TransactionStatus.Aborted, status, "TransactionStatus != Aborted");
}
示例9: ExplicitTransaction8a
public void ExplicitTransaction8a ()
{
CommittableTransaction ct = new CommittableTransaction ();
IntResourceManager irm = new IntResourceManager ( 1 );
using ( TransactionScope scope = new TransactionScope ( ct ) ) {
irm.Value = 2;
scope.Complete ();
/* FIXME: Why TransactionAbortedException ?? */
try {
ct.Commit ();
}
catch ( TransactionAbortedException) {
irm.Check ( 0, 0, 1, 0, "irm" );
return;
}
Assert.Fail ( "Should not be reached" );
}
}
示例10: 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" );
}
示例11: ExplicitTransaction6c
public void ExplicitTransaction6c ()
{
CommittableTransaction ct = new CommittableTransaction ();
IntResourceManager irm = new IntResourceManager ( 1 );
Transaction.Current = ct;
TransactionScope scope1 = new TransactionScope (TransactionScopeOption.RequiresNew);
/* Enlist */
irm.Value = 2;
TransactionScope scope2 = new TransactionScope ();
try {
scope1.Dispose ();
} catch (InvalidOperationException) {
/* Error: TransactionScope nested incorrectly */
irm.Check ( 0, 0, 1, 0, "irm" );
scope2.Dispose ();
Transaction.Current = null;
return;
}
Assert.Fail ("Commit should've failed");
}
示例12: ExplicitTransaction6b
public void ExplicitTransaction6b ()
{
CommittableTransaction ct = new CommittableTransaction ();
IntResourceManager irm = new IntResourceManager ( 1 );
Transaction.Current = ct;
TransactionScope scope1 = new TransactionScope ();
/* Enlist */
irm.Value = 2;
scope1.Complete ();
try {
ct.Commit ();
} catch (TransactionAbortedException) {
irm.Check ( 0, 0, 1, 0, "irm" );
scope1.Dispose ();
Transaction.Current = null;
return;
}
Assert.Fail ( "Commit should've failed" );
}
示例13: ExplicitTransaction5
public void ExplicitTransaction5 ()
{
Assert.IsNull (Transaction.Current, "Ambient transaction exists (before)");
CommittableTransaction ct = new CommittableTransaction ();
Transaction oldTransaction = Transaction.Current;
/* Not setting ambient transaction
Transaction.Current = ct;
*/
IntResourceManager irm = new IntResourceManager (1);
using (TransactionScope scope = new TransactionScope (ct)) {
Assert.AreEqual (ct, Transaction.Current, "#59");
irm.Value = 2;
/* Not completing this scope
scope.Complete (); */
}
Assert.AreEqual (oldTransaction, Transaction.Current, "#60");
Assert.AreEqual (TransactionStatus.Aborted, ct.TransactionInformation.Status, "#61");
Assert.AreEqual (1, irm.Actual, "#62"); /* Actual value */
irm.Check ( 0, 0, 1, 0, "irm");
}
示例14: ExplicitTransaction4
public void ExplicitTransaction4 ()
{
Assert.IsNull (Transaction.Current, "Ambient transaction exists (before)");
CommittableTransaction ct = new CommittableTransaction ();
Transaction oldTransaction = Transaction.Current;
/* Not setting ambient transaction
Transaction.Current = ct;
*/
IntResourceManager irm = new IntResourceManager (1);
using (TransactionScope scope = new TransactionScope (ct)) {
Assert.AreEqual (ct, Transaction.Current, "#53");
irm.Value = 2;
scope.Complete ();
}
Assert.AreEqual (oldTransaction, Transaction.Current, "#54");
Assert.AreEqual (TransactionStatus.Active, ct.TransactionInformation.Status, "#55");
Assert.AreEqual (1, irm.Actual, "#56"); /* Actual value */
ct.Commit ();
Assert.AreEqual (2, irm.Actual, "#57"); /* New committed actual value */
Assert.AreEqual (TransactionStatus.Committed, ct.TransactionInformation.Status, "#58");
irm.Check ( 1, 1, 0, 0, "irm");
}
示例15: ExplicitTransaction2
public void ExplicitTransaction2 ()
{
Assert.IsNull (Transaction.Current, "Ambient transaction exists (before)");
CommittableTransaction ct = new CommittableTransaction ();
Transaction oldTransaction = Transaction.Current;
Transaction.Current = ct;
IntResourceManager irm = new IntResourceManager (1);
irm.Value = 2;
using (TransactionScope scope = new TransactionScope ()) {
Assert.AreEqual (ct, Transaction.Current, "#44");
/* Not calling scope.Complete
scope.Complete ();*/
}
Assert.AreEqual (TransactionStatus.Aborted, ct.TransactionInformation.Status, "#45");
Assert.AreEqual (ct, Transaction.Current, "#46");
Assert.AreEqual (1, irm.Actual, "#47");
Assert.AreEqual (1, irm.NumRollback, "#48");
irm.Check ( 0, 0, 1, 0, "irm" );
Transaction.Current = oldTransaction;
try {
ct.Commit ();
} catch (TransactionAbortedException) {
return;
}
Assert.Fail ("Commit on an aborted transaction should fail");
}