1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
19 using Castle
.Services
.Transaction
;
22 /// Summary description for MockTransactionManager.
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();
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
)
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()
132 public override bool IsChildTransaction
134 get { return false; }
137 public override bool IsRollbackOnlySet
139 get { return rollbackOnly; }