Support ability to scope how global behaviors are applied to clients and services...
[castle.git] / Facilities / AutomaticTransactionManagement / Castle.Facilities.AutomaticTransactionManagement.Tests / MockTransactionManager.cs
blobaf252f800f258c8b1c81b6fc889a7bc9787c6139
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Facilities.AutomaticTransactionManagement.Tests
17 using System;
19 using Castle.Services.Transaction;
21 /// <summary>
22 /// Summary description for MockTransactionManager.
23 /// </summary>
24 public class MockTransactionManager : ITransactionManager
26 private MockTransaction _current;
27 private int _transactions;
28 private int _committedCount;
29 private int _rolledBackCount;
31 public MockTransactionManager()
35 event TransactionCreationInfoDelegate ITransactionManager.TransactionCreated
37 add { throw new NotImplementedException(); }
38 remove { throw new NotImplementedException(); }
41 event TransactionCreationInfoDelegate ITransactionManager.ChildTransactionCreated
43 add { throw new NotImplementedException(); }
44 remove { throw new NotImplementedException(); }
47 event TransactionDelegate ITransactionManager.TransactionCommitted
49 add { throw new NotImplementedException(); }
50 remove { throw new NotImplementedException(); }
53 event TransactionDelegate ITransactionManager.TransactionRolledback
55 add { throw new NotImplementedException(); }
56 remove { throw new NotImplementedException(); }
59 event TransactionDelegate ITransactionManager.TransactionDisposed
61 add { throw new NotImplementedException(); }
62 remove { throw new NotImplementedException(); }
65 event TransactionErrorDelegate ITransactionManager.TransactionFailed
67 add { throw new NotImplementedException(); }
68 remove { throw new NotImplementedException(); }
71 public ITransaction CreateTransaction(TransactionMode transactionMode, IsolationMode isolationMode,
72 bool distributedTransaction)
74 _current = new MockTransaction();
76 _transactions++;
78 return _current;
81 public ITransaction CreateTransaction(TransactionMode transactionMode, IsolationMode isolationMode)
83 return CreateTransaction(transactionMode, isolationMode, false);
86 public void Dispose(ITransaction tran)
88 MockTransaction transaction = (MockTransaction) tran;
90 if (transaction.Status == TransactionStatus.Committed)
92 _committedCount++;
94 else
96 _rolledBackCount++;
99 _current = null;
102 public ITransaction CurrentTransaction
104 get { return _current; }
107 public int TransactionCount
109 get { return _transactions; }
112 public int CommittedCount
114 get { return _committedCount; }
117 public int RolledBackCount
119 get { return _rolledBackCount; }
123 public class MockTransaction : AbstractTransaction
125 private bool rollbackOnly;
127 public override void SetRollbackOnly()
129 rollbackOnly = true;
132 public override bool IsChildTransaction
134 get { return false; }
137 public override bool IsRollbackOnlySet
139 get { return rollbackOnly; }