Thread: [Adapdev-commits] Adapdev/src/Adapdev.UnitTest.Core AutoCommitCommand.cs,NONE,1.1 AutoRollbackComman
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2005-11-11 04:52:54
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25387/src/Adapdev.UnitTest.Core Modified Files: Adapdev.UnitTest.Core.csproj RunTestIterationCommand.cs TestSuiteBuilder.cs TestUnit.cs Added Files: AutoCommitCommand.cs AutoRollbackCommand.cs IThreadWorkItemCommand.cs TransactionType.cs Log Message: Added support for mutli-threaded tests (still buggy) and transactional tests Added new ISelectQuery.AddJoin method allowing for the joining of four tables Fixed bug w/ DatabaseSchema persistence Index: TestSuiteBuilder.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TestSuiteBuilder.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TestSuiteBuilder.cs 26 Oct 2005 05:27:45 -0000 1.10 --- TestSuiteBuilder.cs 11 Nov 2005 04:52:46 -0000 1.11 *************** *** 213,216 **** --- 213,217 ---- this.ProcessMaxKAttribute(m, t); this.ProcessMinOperationsPerSecondAttribute(m, t); + this.ProcessTransactionAttribute(m, t); if(log.IsDebugEnabled) log.Debug("Test built: " + t.ToString()); *************** *** 347,350 **** --- 348,363 ---- } + public void ProcessTransactionAttribute(ICustomAttributeProvider m, Test t) + { + if (TypeHelper.HasCustomAttribute(m, typeof(Adapdev.UnitTest.TransactionAttribute))) + { + t.TransactionType = TransactionType.AutoCommit; + } + else if (TypeHelper.HasCustomAttribute(m, typeof(Adapdev.UnitTest.RollbackTransactionAttribute))) + { + t.TransactionType = TransactionType.AutoRollback; + } + } + public void ProcessTestSetUpAttribute(ICustomAttributeProvider mi, TestHelper t) { Index: TestUnit.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TestUnit.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TestUnit.cs 28 Feb 2005 01:32:23 -0000 1.1.1.1 --- TestUnit.cs 11 Nov 2005 04:52:46 -0000 1.2 *************** *** 48,51 **** --- 48,52 ---- protected int _maxK = 0; protected ArrayList _attributes = new ArrayList(); + protected TransactionType _transaction = TransactionType.None; public TestUnit() *************** *** 65,68 **** --- 66,75 ---- } + public TransactionType TransactionType + { + get{return this._transaction;} + set{this._transaction = value;} + } + public void AddAttribute(Attribute a) { --- NEW FILE: IThreadWorkItemCommand.cs --- using System; using Adapdev.Commands; namespace Adapdev.UnitTest.Core { /// <summary> /// Summary description for IThreadWorkItemCommand. /// </summary> public interface IThreadWorkItemCommand : ICommand { void Execute(object o); } } --- NEW FILE: TransactionType.cs --- using System; namespace Adapdev.UnitTest.Core { /// <summary> /// Summary description for TransactionType. /// </summary> public enum TransactionType { None, AutoCommit, AutoRollback } } Index: RunTestIterationCommand.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/RunTestIterationCommand.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RunTestIterationCommand.cs 1 Nov 2005 05:41:40 -0000 1.1 --- RunTestIterationCommand.cs 11 Nov 2005 04:52:46 -0000 1.2 *************** *** 4,7 **** --- 4,8 ---- using System.Reflection; using System.Threading; + using Adapdev.Commands; using Adapdev.Diagnostics; *************** *** 11,15 **** /// Summary description for RunTestIterationCommand. /// </summary> ! public class RunTestIterationCommand { private TestEventDispatcher _dispatcher = null; --- 12,16 ---- /// Summary description for RunTestIterationCommand. /// </summary> ! public class RunTestIterationCommand : IThreadWorkItemCommand { private TestEventDispatcher _dispatcher = null; *************** *** 72,77 **** kStart = Process.GetCurrentProcess().WorkingSet; timer.Start(); ! ! new RunMethodCommand(this._method, o).Execute(); timer.Stop(); --- 73,83 ---- kStart = Process.GetCurrentProcess().WorkingSet; timer.Start(); ! ! // Check for transactions and run ! ICommand command = new RunMethodCommand(this._method, o); ! if(this._test.TransactionType == TransactionType.AutoCommit) command = new AutoCommitCommand(command); ! else if(this._test.TransactionType == TransactionType.AutoRollback) command = new AutoRollbackCommand(command); ! command.Execute(); ! timer.Stop(); --- NEW FILE: AutoCommitCommand.cs --- using System; using Adapdev.Commands; using Adapdev.Transactions; namespace Adapdev.UnitTest.Core { /// <summary> /// Summary description for AutoCommitTestCommand. /// </summary> public class AutoCommitCommand : IThreadWorkItemCommand { private ICommand _command; public AutoCommitCommand(ICommand command) { this._command = command; } #region ICommand Members public void Execute() { using(TransactionScope transction = new TransactionScope()) { this._command.Execute(); } } #endregion public void Execute(object o){this.Execute();} } } Index: Adapdev.UnitTest.Core.csproj =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/Adapdev.UnitTest.Core.csproj,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Adapdev.UnitTest.Core.csproj 1 Nov 2005 05:41:40 -0000 1.6 --- Adapdev.UnitTest.Core.csproj 11 Nov 2005 04:52:46 -0000 1.7 *************** *** 142,145 **** --- 142,155 ---- /> <File + RelPath = "AutoCommitCommand.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "AutoRollbackCommand.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "BaseTestHelper.cs" SubType = "Code" *************** *** 167,170 **** --- 177,185 ---- /> <File + RelPath = "IThreadWorkItemCommand.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "LocalSeparateTestEngine.cs" SubType = "Code" *************** *** 362,365 **** --- 377,385 ---- /> <File + RelPath = "TransactionType.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "TypeHelper.cs" SubType = "Code" --- NEW FILE: AutoRollbackCommand.cs --- using System; using Adapdev.Commands; using Adapdev.Transactions; namespace Adapdev.UnitTest.Core { /// <summary> /// Summary description for AutoRollbackCommand. /// </summary> public class AutoRollbackCommand : IThreadWorkItemCommand { private ICommand _command; public AutoRollbackCommand(ICommand command) { this._command = command; } #region ICommand Members public void Execute() { using(TransactionScope transaction = new TransactionScope()) { this._command.Execute(); transaction.Abort(); } } #endregion public void Execute(object o){this.Execute();} } } |