[Adapdev-commits] Adapdev/src/Adapdev.UnitTest.Core AbstractTest.cs,1.5,1.6 AbstractTestEventArgs.cs
Status: Beta
Brought to you by:
intesar66
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv909/src/Adapdev.UnitTest.Core Added Files: AbstractTest.cs AbstractTestEventArgs.cs AbstractTestIteration.cs AbstractTestResult.cs AbstractTestVisitor.cs Adapdev.UnitTest.Core.csproj AssemblyWatcher.cs AutoCommitCommand.cs AutoRollbackCommand.cs BaseTestHelper.cs CompositeAbstractTestIteration.cs ErrorEventArgs.cs IResultFormatter.cs ITestEngine.cs IThreadWorkItemCommand.cs LocalSeparateTestEngine.cs LocalTestEngine.cs RunMethodCommand.cs RunNonThreadedTestCommand.cs RunTestCommand.cs RunTestFixtureCommand.cs RunTestIterationCommand.cs RunThreadedTestCommand.cs Test.cs TestAssembly.cs TestAssemblyEventArgs.cs TestAssemblyIteration.cs TestAssemblyIterationEventArgs.cs TestAssemblyResult.cs TestAssemblyResultEventArgs.cs TestEngineFactory.cs TestEngineType.cs TestEventArgs.cs TestEventDispatcher.cs TestFixture.cs TestFixtureEventArgs.cs TestFixtureIteration.cs TestFixtureIterationEventArg.cs TestFixtureResult.cs TestFixtureResultEventArg.cs TestFramework.cs TestHelper.cs TestHelperEventArgs.cs TestIteration.cs TestIterationEventArgs.cs TestResult.cs TestResultEventArgs.cs TestRunner.cs TestState.cs TestSuite.cs TestSuiteBuilder.cs TestSuiteIteration.cs TestSuiteResult.cs TestSummary.cs TestUnit.cs TextFormatter.cs TransactionType.cs TypeHelper.cs VSProject.cs VSProjectConfig.cs VSProjectConfigCollection.cs XmlFormatter.cs Log Message: --- NEW FILE: TestIterationEventArgs.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; /// <summary> /// Summary description for TestIterationEventArgs. /// </summary> /// [Serializable] public class TestIterationEventArgs : EventArgs { private TestIteration _ti = null; public TestIterationEventArgs(TestIteration ti) { this._ti = ti; } public TestIteration TestIteration { get { return this._ti; } set { this._ti = value; } } } } --- NEW FILE: TestSummary.cs --- using System; namespace Adapdev.UnitTest.Core { /// <summary> /// Summary description for TestSummary. /// </summary> public class TestSummary { private TestAssemblyResult[] tar = null; public TestSummary(TestAssemblyResult[] tar) { this.tar = tar; } public int TotalFailed { get { int total = 0; foreach (TestAssemblyResult testAssemblyResult in tar) { total += testAssemblyResult.Failed; } return total; } } public int TotalPassed { get { int total = 0; foreach (TestAssemblyResult testAssemblyResult in tar) { total += testAssemblyResult.Passed; } return total; } } public int TotalIgnored { get { int total = 0; foreach (TestAssemblyResult testAssemblyResult in tar) { total += testAssemblyResult.Ignored; } return total; } } public double PercentPassed { get { int passed = this.TotalPassed; int failed = this.TotalFailed; if ((passed + failed) > 0) return (Convert.ToDouble(passed)/Convert.ToDouble(passed + failed)); else return 0; } } public double PercentFailed { get{return 1 - this.PercentPassed;} } public double TotalDuration { get { double duration = 0; foreach(TestAssemblyResult t in this.tar) { duration += t.GetTotalDuration(); } return duration; } } } } --- NEW FILE: IThreadWorkItemCommand.cs --- using System; using Adapdev.Commands; namespace Adapdev.UnitTest.Core { /// <summary> /// Summary description for IThreadWorkItemCommand. /// </summary> public interface IThreadWorkItemCommand : ICommand { object Execute(object o); } } --- NEW FILE: VSProjectConfig.cs --- #region Original Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig /************************************************************************************ ' ' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole ' Copyright 2000-2002 Philip A. Craig ' ' This software is provided 'as-is', without any express or implied warranty. In no ' event will the authors be held liable for any damages arising from the use of this ' software. ' ' Permission is granted to anyone to use this software for any purpose, including ' commercial applications, and to alter it and redistribute it freely, subject to the ' following restrictions: ' ' 1. The origin of this software must not be misrepresented; you must not claim that ' you wrote the original software. If you use this software in a product, an ' acknowledgment (see the following) in the product documentation is required. ' ' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole ' or Copyright 2000-2002 Philip A. Craig ' ' 2. Altered source versions must be plainly marked as such, and must not be ' misrepresented as being the original software. ' ' 3. This notice may not be removed or altered from any source distribution. ' '***********************************************************************************/ #endregion #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System.Collections.Specialized; /// <summary> /// Originally, we used the same ProjectConfig class for both /// NUnit and Visual Studio projects. Since we really do very /// little with VS Projects, this class has been created to /// hold the name and the collection of assembly paths. /// </summary> public class VSProjectConfig { private string name; private StringCollection assemblies = new StringCollection(); public VSProjectConfig(string name) { this.name = name; } public string Name { get { return name; } } public StringCollection Assemblies { get { return assemblies; } } } } --- NEW FILE: TestHelperEventArgs.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; /// <summary> /// Summary description for BaseTestHelperEventArgs. /// </summary> [Serializable] public class BaseTestHelperEventArgs { private BaseTestHelper _ti = null; public BaseTestHelperEventArgs(BaseTestHelper th) { this._ti = th; } public BaseTestHelper BaseTestHelper { get { return this._ti; } set { this._ti = value; } } } } --- NEW FILE: TestAssemblyResultEventArgs.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; /// <summary> /// Summary description for TestAssemblyResultEventArgs. /// </summary> /// [Serializable] public class TestAssemblyResultEventArgs : EventArgs { private TestAssemblyResult _ti = null; public TestAssemblyResultEventArgs(TestAssemblyResult ti) { this._ti = ti; } public TestAssemblyResult TestAssemblyResult { get { return this._ti; } set { this._ti = value; } } } } --- NEW FILE: TypeHelper.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; using System.Reflection; /// <summary> /// Summary description for TypeHelper. /// </summary> public class TypeHelper { public static bool HasCustomAttribute(ICustomAttributeProvider t, Type customAttributeType) { if (t == null) throw new ArgumentNullException("t"); if (customAttributeType == null) throw new ArgumentNullException("customAttributeType"); return t.GetCustomAttributes(customAttributeType, true).Length != 0; } public static Object GetFirstCustomAttribute(ICustomAttributeProvider mi, Type customAttributeType) { if (mi == null) throw new ArgumentNullException("mi"); if (customAttributeType == null) throw new ArgumentNullException("customAttributeType"); Object[] attrs = mi.GetCustomAttributes(customAttributeType, true); if (attrs.Length == 0) throw new ArgumentException("type does not have custom attribute"); return attrs[0]; } } } --- NEW FILE: TestFixtureIterationEventArg.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; /// <summary> /// Summary description for TestIterationEventArgs. /// </summary> /// [Serializable] public class TestFixtureIterationEventArgs : EventArgs { private TestFixtureIteration _ti = null; public TestFixtureIterationEventArgs(TestFixtureIteration ti) { this._ti = ti; } public TestFixtureIteration TestFixtureIteration { get { return this._ti; } set { this._ti = value; } } } } --- NEW FILE: CompositeAbstractTestIteration.cs --- using System; using System.Collections; namespace Adapdev.UnitTest.Core { /// <summary> /// Summary description for CompositeAbstractTestIteration. /// </summary> /// [Serializable] public class CompositeAbstractTestIteration : AbstractTestIteration { protected Hashtable _results = new Hashtable(); public void AddTestResult(AbstractTestResult tr) { this._results[tr.Name] = tr; if (tr.State == TestState.Fail) this._state = TestState.Fail; if (this._state != TestState.Fail) { if (tr.State == TestState.Pass) this._state = TestState.Pass; } } public ICollection GetTestResults() { return this._results.Values; } public override double Duration { get { double d = 0; foreach (AbstractTestResult tr in this.GetTestResults()) { d += tr.GetTotalDuration(); } return d; } } public AbstractTestResult GetTestResult(string name) { return this._results[name] as AbstractTestResult; } } } --- NEW FILE: RunMethodCommand.cs --- using System; using System.Reflection; using Adapdev.Commands; namespace Adapdev.UnitTest.Core { /// <summary> /// Summary description for RunMethodCommand. /// </summary> public class RunMethodCommand : ICommand { private MethodInfo _method = null; private object _o = null; public RunMethodCommand(MethodInfo method, object o) { this._method = method; this._o = o; } public void Execute() { this._method.Invoke(this._o, null); } } } --- NEW FILE: TestAssembly.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; using System.Collections; /// <summary> /// Summary description for TestAssembly. /// </summary> /// [Serializable] public class TestAssembly : AbstractTest { protected Hashtable _fixtures = new Hashtable(); protected string _assemblyName = String.Empty; protected string _assemblyFullName = String.Empty; protected TestSuite _parent = null; protected string _path = String.Empty; protected string _location = String.Empty; protected string _original = String.Empty; protected string _configFile = String.Empty; public TestAssembly() { } public TestAssembly(string name) { this.AssemblyName = name; this.Name = name; } public string ConfigFile { get { return _configFile; } set { _configFile = value; } } public string Path { get { return this._path; } set { this._path = value; } } public string AssemblyName { get { return this._assemblyName; } set { this._assemblyName = value; } } public string AssemblyFullName { get { return this._assemblyFullName; } set { this._assemblyFullName = value; } } public string OriginalPath { get{return this._original;} set{this._original = value;} } public TestSuite Parent { get { return this._parent; } set { this._parent = value; } } public string Location { get { return this._location; } set { this._location = value; } } public void AddTestFixture(TestFixture tf) { if (tf != null) this._fixtures[tf.Id] = tf; } public void RemoveTestFixture(TestFixture tf) { if (tf != null) this._fixtures.Remove(tf.Id); } public void RemoveTestFixture(string id) { this._fixtures.Remove(id); } public override int GetTestCount() { if (!this.Ignore) { int count = 0; foreach (TestFixture t in this.GetTestFixtures()) { if(t.ShouldRun && !t.Ignore) { count += t.GetTestCount(); } } return count*this.RepeatCount; } else { return 0; } } public ICollection GetTestFixtures() { return this._fixtures.Values; } } } --- NEW FILE: TestFixtureIteration.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; [Serializable] public class TestFixtureIteration : CompositeAbstractTestIteration { } } --- NEW FILE: TestAssemblyIterationEventArgs.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; /// <summary> /// Summary description for TestAssemblyIterationEventArgs. /// </summary> /// [Serializable] public class TestAssemblyIterationEventArgs : EventArgs { private TestAssemblyIteration _ti = null; public TestAssemblyIterationEventArgs(TestAssemblyIteration ti) { this._ti = ti; } public TestAssemblyIteration TestAssemblyIteration { get { return this._ti; } set { this._ti = value; } } } } --- NEW FILE: XmlFormatter.cs --- using System.IO; namespace Adapdev.UnitTest.Core { using System; using System.Diagnostics; using System.Text; using System.Xml; /// <summary> /// Summary description for XmlFormatter. /// </summary> public class XmlFormatter : IResultFormatter { private XmlDocument xml = null; public XmlFormatter(TestAssemblyResult[] results){ this.FormatResults(results); } protected void FormatTestResult(TestResult tr, XmlNode testFixtureIteration) { Debug.Assert(tr != null); XmlNode testResult = xml.CreateElement("testResult"); XmlAttribute avgOpsSecond = xml.CreateAttribute("avgOpsSecond"); avgOpsSecond.Value = tr.GetAvgOpsPerSecond().ToString(); testResult.Attributes.Append(avgOpsSecond); XmlAttribute totalDuration = xml.CreateAttribute("totalDuration"); totalDuration.Value = tr.GetTotalDuration().ToString(); testResult.Attributes.Append(totalDuration); XmlAttribute category = xml.CreateAttribute("category"); category.Value = tr.Category; testResult.Attributes.Append(category); XmlAttribute description = xml.CreateAttribute("description"); description.Value = tr.Description; testResult.Attributes.Append(description); this.FormatAbstractTestResult(tr, testResult); foreach (TestIteration ti in tr.Iterations) { XmlNode testIteration = xml.CreateElement("testIteration"); XmlAttribute iteration = xml.CreateAttribute("iteration"); iteration.Value = ti.Iteration.ToString(); testIteration.Attributes.Append(iteration); XmlNode tcategory = xml.CreateElement("category"); testIteration.AppendChild(tcategory); XmlNode tcategorytext = xml.CreateCDataSection(tr.Category); tcategory.AppendChild(tcategorytext); XmlNode tmessage = xml.CreateElement("message"); testIteration.AppendChild(tmessage); XmlNode tmessagetext = xml.CreateCDataSection(ti.Result); tmessage.AppendChild(tmessagetext); XmlNode texception = xml.CreateElement("exception"); testIteration.AppendChild(texception); XmlNode texceptiontext = xml.CreateCDataSection(ti.FullStackTrace); texception.AppendChild(texceptiontext); XmlNode tduration = xml.CreateElement("duration"); tduration.InnerText = ti.Duration.ToString(); testIteration.AppendChild(tduration); XmlNode thread = xml.CreateElement("thread"); thread.InnerText = ti.Thread.ToString(); testIteration.AppendChild(thread); XmlNode state = xml.CreateElement("state"); state.InnerText = ti.State.ToString(); testIteration.AppendChild(state); XmlNode opsSecond = xml.CreateElement("opsSecond"); opsSecond.InnerText = ti.GetOpsPerSecond().ToString(); testIteration.AppendChild(opsSecond); XmlNode output = xml.CreateElement("consoleOutput"); testIteration.AppendChild(output); XmlNode outputText = xml.CreateCDataSection(ti.ConsoleOutput); output.AppendChild(outputText); XmlNode consoleError = xml.CreateElement("consoleError"); testIteration.AppendChild(consoleError); XmlNode consoleErrorText = xml.CreateCDataSection(ti.ConsoleError); consoleError.AppendChild(consoleErrorText); XmlNode debugOutput = xml.CreateElement("debugOutput"); testIteration.AppendChild(debugOutput); XmlNode debugOutputText = xml.CreateCDataSection(ti.DebugOutput); debugOutput.AppendChild(debugOutputText); XmlNode traceOutput = xml.CreateElement("traceOutput"); testIteration.AppendChild(traceOutput); XmlNode traceOutputText = xml.CreateCDataSection(ti.TraceOutput); traceOutput.AppendChild(traceOutputText); XmlNode allOutput = xml.CreateElement("allOutput"); testIteration.AppendChild(allOutput); XmlNode allOutputText = xml.CreateCDataSection(ti.AllOutput); allOutput.AppendChild(allOutputText); testResult.AppendChild(testIteration); } testFixtureIteration.AppendChild(testResult); } protected void FormatTestFixtureResult(TestFixtureResult tfr, XmlNode testAssemblyIteration) { Debug.Assert(tfr != null); XmlNode testFixtureResult = xml.CreateElement("testFixtureResult"); XmlAttribute totalDuration = xml.CreateAttribute("totalDuration"); totalDuration.Value = tfr.GetTotalDuration().ToString(); testFixtureResult.Attributes.Append(totalDuration); this.FormatAbstractTestResult(tfr, testFixtureResult); int i = 1; foreach (TestFixtureIteration tfi in tfr.Iterations) { XmlNode testFixtureIteration = xml.CreateElement("testFixtureIteration"); XmlAttribute iteration = xml.CreateAttribute("iteration"); iteration.Value = i.ToString(); testFixtureIteration.Attributes.Append(iteration); XmlAttribute totalDuration2 = xml.CreateAttribute("totalDuration"); totalDuration2.Value = tfr.GetTotalDuration().ToString(); testFixtureIteration.Attributes.Append(totalDuration2); XmlAttribute state = xml.CreateAttribute("state"); state.Value = tfr.GetTotalDuration().ToString(); testFixtureIteration.Attributes.Append(state); foreach (TestResult tr in tfi.GetTestResults()) { this.FormatTestResult(tr, testFixtureIteration); } testFixtureResult.AppendChild(testFixtureIteration); i++; } testAssemblyIteration.AppendChild(testFixtureResult); } protected void FormatTestAssemblyResult(TestAssemblyResult tar, XmlNode resultNode) { Debug.Assert(tar != null); XmlNode testAssemblyResult = xml.CreateNode(XmlNodeType.Element, "testAssemblyResult", ""); XmlAttribute runTime = xml.CreateAttribute("runTime"); runTime.Value = tar.RunTime.ToString(); testAssemblyResult.Attributes.Append(runTime); XmlAttribute assemblyName = xml.CreateAttribute("assemblyName"); assemblyName.Value = tar.AssemblyName; testAssemblyResult.Attributes.Append(assemblyName); XmlAttribute assemblyFullName = xml.CreateAttribute("assemblyFullName"); assemblyFullName.Value = tar.AssemblyFullName; testAssemblyResult.Attributes.Append(assemblyFullName); XmlAttribute location = xml.CreateAttribute("location"); location.Value = tar.Location; testAssemblyResult.Attributes.Append(location); this.FormatAbstractTestResult(tar, testAssemblyResult); int i = 1; foreach (TestAssemblyIteration tai in tar.Iterations) { XmlNode testAssemblyIteration = xml.CreateElement("testAssemblyIteration"); XmlAttribute iteration = xml.CreateAttribute("iteration"); iteration.Value = i.ToString(); testAssemblyIteration.Attributes.Append(iteration); XmlAttribute totalDuration = xml.CreateAttribute("totalDuration"); totalDuration.Value = tai.Duration.ToString(); testAssemblyIteration.Attributes.Append(totalDuration); XmlAttribute state = xml.CreateAttribute("state"); state.Value = tai.State.ToString(); testAssemblyIteration.Attributes.Append(state); foreach (TestFixtureResult tfr in tai.GetTestResults()) { this.FormatTestFixtureResult(tfr, testAssemblyIteration); } testAssemblyResult.AppendChild(testAssemblyIteration); i++; } resultNode.AppendChild(testAssemblyResult); } public void FormatResults(TestAssemblyResult[] tars) { Debug.Assert(tars != null); xml = new XmlDocument(); // xml.AppendChild(xml.CreateProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"")); XmlNode results = xml.CreateNode(XmlNodeType.Element, "results",String.Empty); xml.AppendChild(results); if (tars != null) { foreach (TestAssemblyResult tar in tars) { this.FormatTestAssemblyResult(tar, results); } } } protected void FormatAbstractTestResult(AbstractTestResult atr, XmlNode testResult) { Debug.Assert(atr != null); XmlAttribute name = xml.CreateAttribute("name"); name.Value = atr.Name; testResult.Attributes.Append(name); XmlAttribute avgDuration = xml.CreateAttribute("avgDuration"); avgDuration.Value = atr.GetAverageDuration().ToString(); testResult.Attributes.Append(avgDuration); XmlAttribute totalIterations = xml.CreateAttribute("totalIterations"); totalIterations.Value = atr.GetTotalIterations().ToString(); testResult.Attributes.Append(totalIterations); XmlAttribute state = xml.CreateAttribute("state"); state.Value = atr.State.ToString(); testResult.Attributes.Append(state); XmlAttribute id = xml.CreateAttribute("id"); id.Value = atr.TestId.ToString(); testResult.Attributes.Append(id); XmlAttribute passed = xml.CreateAttribute("passed"); passed.Value = atr.Passed.ToString(); testResult.Attributes.Append(passed); XmlAttribute failed = xml.CreateAttribute("failed"); failed.Value = atr.Failed.ToString(); testResult.Attributes.Append(failed); XmlAttribute ignored = xml.CreateAttribute("ignored"); ignored.Value = atr.Ignored.ToString(); testResult.Attributes.Append(ignored); XmlAttribute percentPassed = xml.CreateAttribute("percentPassed"); percentPassed.Value = atr.PercentPassed.ToString("p"); testResult.Attributes.Append(percentPassed); XmlAttribute percentFailed = xml.CreateAttribute("percentFailed"); percentFailed.Value = atr.PercentFailed.ToString("p"); testResult.Attributes.Append(percentFailed); } public string GetText(){ StringWriter sw = new StringWriter(); XmlTextWriter xtw = new XmlTextWriter(sw); xtw.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); xml.Save(sw); return sw.ToString().Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>",""); } } } --- NEW FILE: RunNonThreadedTestCommand.cs --- using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Threading; using Adapdev.Commands; using Adapdev.Diagnostics; using log4net; namespace Adapdev.UnitTest.Core { /// <summary> /// Summary description for NonThreadedRunTestCommand. /// </summary> public class RunNonThreadedTestCommand : ICommand { private MethodInfo _method = null; private object _o = null; // create the logger private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // setup the logging levels private bool _debugMode = log.IsDebugEnabled; private bool _infoMode = log.IsInfoEnabled; private IPerfTimer timer = PerfTimerFactory.GetPerfTimer(PerfTimerType.HIRESSECONDS); private TestEventDispatcher _dispatcher = null; private Test _test = null; private TestFixture _testFixture = null; private Type _type = null; private object o = null; private TestFixtureIteration _testFixtureIteration = null; public RunNonThreadedTestCommand(TestEventDispatcher dispatcher, Test test, TestFixture tf, Type type, object o, TestFixtureIteration tfi) { this._dispatcher = dispatcher; this._test = test; this._testFixture = tf; this.o = o; this._testFixtureIteration = tfi; this._type = type; } public void Execute() { try { MethodInfo m = _type.GetMethod(_test.Method); TestResult tr = new TestResult(_test); tr.TestId = _test.Id; tr.Description = _test.Description; if(this._debugMode) log.Debug("Running T " + _test.Name); if (!_test.Ignore && _test.ShouldRun) { if(_dispatcher != null)_dispatcher.OnTestStarted(new TestEventArgs(_test)); for (int i = 1; i <= _test.RepeatCount; i++) { TextWriter consoleOut = Console.Out; TextWriter errorOut = Console.Error; StringWriter consoleWriter = new StringWriter(); StringWriter errorWriter = new StringWriter(); StringWriter debugWriter = new StringWriter(); StringWriter traceWriter = new StringWriter(); //Console.SetOut(consoleWriter); Console.SetError(errorWriter); TextWriterTraceListener debug = new TextWriterTraceListener(debugWriter); TextWriterTraceListener error = new TextWriterTraceListener(traceWriter); Debug.Listeners.Add(debug); Trace.Listeners.Add(error); if (_test.RepeatDelay > 0) { Thread.Sleep(_test.RepeatDelay); Console.WriteLine("Sleeping..." + _test.RepeatDelay); } TestIteration ti = new TestIteration(); ti.Name = _test.Name; ti.Iteration = i; ti.Thread = AppDomain.GetCurrentThreadId().ToString(); long kStart = 0; long kEnd = 0; if(_dispatcher != null)_dispatcher.OnTestIterationStarted(new TestEventArgs(_test)); try { this.RunTestSetUps(_dispatcher, _testFixture, _test.Name, o, _type); kStart = Process.GetCurrentProcess().WorkingSet; timer.Start(); new RunMethodCommand(m, o).Execute(); timer.Stop(); ti.Duration = timer.Duration; kEnd = Process.GetCurrentProcess().WorkingSet; ti.MemoryUsed = (kEnd - kStart)/1024; if (_test.MaxKMemory > 0 && _test.MaxKMemory < ti.MemoryUsed) { ti.State = TestState.Fail; ti.Result = "Memory usage exceeded MaxK limit of " + _test.MaxKMemory; } else if (_test.MinOperationsPerSecond > 0 && ti.GetOpsPerSecond() < _test.MinOperationsPerSecond) { ti.State = TestState.Fail; ti.Result = "Ops per second was less than minimum limit of " + _test.MinOperationsPerSecond; } else if (_test.ExpectedExceptionType != null && _test.ExpectedExceptionType.Length > 0) { ti.State = TestState.Fail; ti.Result = "ExceptedException type " + _test.ExpectedExceptionType + " was not thrown."; } else { ti.State = TestState.Pass; } this.RunTestTearDowns(_dispatcher, _testFixture, _test.Name, o, _type); } catch (Exception e) { timer.Stop(); ti.Duration = timer.Duration; kEnd = Process.GetCurrentProcess().WorkingSet; if (_test.ExpectedExceptionType != null && _test.ExpectedExceptionType.Length > 0) { Type t = null; foreach(Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) { try { t = ass.GetType(_test.ExpectedExceptionType, true, true); break; } catch(Exception){} } if(t == null) throw new TypeLoadException("Unable to locate " + _test.ExpectedExceptionType + ". Please make sure it is correct."); if (e.InnerException.GetType().IsSubclassOf(t) || e.InnerException.GetType() == t) { if(_test.ExpectedExceptionMessage != null && _test.ExpectedExceptionMessage.Length > 0) { if(_test.ExpectedExceptionMessage.ToLower() == e.InnerException.Message.ToLower()) { ti.Result = "Expected Exception: " + _test.ExpectedExceptionType + " was thrown. Message: " + e.InnerException.Message; ti.State = TestState.Pass; } else { ti.Result = "Expected Exception: " + _test.ExpectedExceptionType + " was thrown, but wrong message. Message: " + e.InnerException.Message + " - Expected: " + _test.ExpectedExceptionMessage; ti.State = TestState.Fail; } } else { ti.Result = "Expected Exception: " + _test.ExpectedExceptionType + " was thrown. Message: " + e.InnerException.Message; ti.State = TestState.Pass; } } else { ti.Result = "Expected Exception: " + _test.ExpectedExceptionType + " was NOT thrown. Message: " + e.InnerException.Message; ti.State = TestState.Fail; } ti.ExceptionType = e.InnerException.GetType().FullName; ti.FullStackTrace = e.InnerException.StackTrace; ti.MemoryUsed = (kEnd - kStart)/1024; } // TODO : Fix incrementing of tests in GUI when IgnoreException is thrown else if(e.InnerException.GetType() == typeof(IgnoreException) || e.InnerException.GetType() == typeof(IgnoreException)) { ti.Result = e.InnerException.Message; ti.State = TestState.ForcedIgnore; ti.ExceptionType = e.InnerException.GetType().FullName; ti.FullStackTrace = e.InnerException.StackTrace; } else { ti.Result = e.InnerException.Message; ti.ExceptionType = e.InnerException.GetType().FullName; ti.FullStackTrace = e.InnerException.StackTrace; ti.State = TestState.Fail; } this.RunTestTearDowns(_dispatcher, _testFixture, _test.Name, o, _type); } ti.ConsoleOutput = consoleWriter.ToString(); ti.ConsoleError = errorWriter.ToString(); ti.DebugOutput = debugWriter.ToString(); ti.TraceOutput = traceWriter.ToString(); lock(this){tr.AddIteration(ti);} if(_dispatcher != null)_dispatcher.OnTestIterationCompleted(new TestIterationEventArgs(ti)); Console.SetOut(consoleOut); Console.SetError(errorOut); Debug.Listeners.Remove(debug); Trace.Listeners.Remove(error); debug.Dispose(); error.Dispose(); } } else { TestIteration ti = new TestIteration(); ti.Name = _test.Name; ti.State = TestState.Ignore; ti.Result = _test.IgnoreReason; tr.AddIteration(ti); } if (_testFixture.ShouldShow) _testFixtureIteration.AddTestResult(tr); if(_dispatcher != null)_dispatcher.OnTestCompleted(new TestResultEventArgs(tr)); } catch (Exception e) { Console.WriteLine(e.Message + " " + e.StackTrace); } finally { } } protected void RunTestSetUps(TestEventDispatcher _dispatcher, TestFixture tf, string name, object instance, Type type) { foreach (TestHelper t in tf.GetTestSetUps()) { try { // Console.WriteLine(t.Method); if (t.Test.Length < 1 || t.Test.ToLower().Equals(name.ToLower())) { if(_dispatcher != null)_dispatcher.OnBaseTestHelperStarted(new BaseTestHelperEventArgs(t)); MethodInfo m = type.GetMethod(t.Method); m.Invoke(instance, null); } } catch (Exception e) { Console.Write(e); } } } protected void RunTestTearDowns(TestEventDispatcher _dispatcher, TestFixture tf, string name, object instance, Type type) { foreach (TestHelper t in tf.GetTestTearDowns()) { try { if (t.Test.Length < 1 || t.Test.ToLower().Equals(name.ToLower())) { if(_dispatcher != null)_dispatcher.OnBaseTestHelperStarted(new BaseTestHelperEventArgs(t)); MethodInfo m = type.GetMethod(t.Method); m.Invoke(instance, null); } } catch (Exception e) { Console.Write(e); } } } public void Execute(object o){this.Execute();} } } --- NEW FILE: TestAssemblyIteration.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; using System.Collections; /// <summary> /// Summary description for TestAssemblyIteration. /// </summary> /// [Serializable] public class TestAssemblyIteration : CompositeAbstractTestIteration { } } --- NEW FILE: TestSuite.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; using System.Collections; using Adapdev.IO; /// <summary> /// Summary description for TestSuite. /// </summary> /// [Serializable] public class TestSuite { protected Hashtable _assemblies = new Hashtable(); protected int failedTestCount = 0; protected int passedTestCount = 0; protected int ignoredTestCount = 0; protected double _duration = 0; public TestSuite(){} public void AddTestAssembly(TestAssembly ta) { this._assemblies[ta.Name] = ta; } public ICollection GetTestAssemblies() { return this._assemblies.Values; } public TestAssembly GetTestAssembly(string name) { return this._assemblies[name] as TestAssembly; } public int GetTestCount() { int count = 0; foreach (TestAssembly ta in this.GetTestAssemblies()) { if(ta.ShouldRun && !ta.Ignore) { count += ta.GetTestCount(); } } return count; } public int FailedTestCount { get { return this.failedTestCount; } set { this.failedTestCount = value; } } public int IgnoredTestCount { get { return this.ignoredTestCount; } set { this.ignoredTestCount = value; } } public int PassedTestCount { get { return this.passedTestCount; } set { this.passedTestCount = value; } } public double PercentPassed { get { if ((this.passedTestCount + this.failedTestCount) > 0) return (Convert.ToDouble(this.passedTestCount)/Convert.ToDouble(this.passedTestCount + this.failedTestCount)); else return 0; } } } } --- NEW FILE: AssemblyWatcher.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion #region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig /************************************************************************************ ' ' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole ' Copyright 2000-2002 Philip A. Craig ' ' This software is provided 'as-is', without any express or implied warranty. In no ' event will the authors be held liable for any damages arising from the use of this ' software. ' ' Permission is granted to anyone to use this software for any purpose, including ' commercial applications, and to alter it and redistribute it freely, subject to the ' following restrictions: ' ' 1. The origin of this software must not be misrepresented; you must not claim that ' you wrote the original software. If you use this software in a product, an ' acknowledgment (see the following) in the product documentation is required. ' ' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole ' or Copyright 2000-2002 Philip A. Craig ' ' 2. Altered source versions must be plainly marked as such, and must not be ' misrepresented as being the original software. ' ' 3. This notice may not be removed or altered from any source distribution. ' '***********************************************************************************/ #endregion namespace Adapdev.UnitTest.Core { using System; using System.Collections; using System.IO; using System.Timers; /// <summary> /// AssemblyWatcher keeps track of one or more assemblies to /// see if they have changed. It incorporates a delayed notification /// and uses a standard event to notify any interested parties /// about the change. The path to the assembly is provided as /// an argument to the event handler so that one routine can /// be used to handle events from multiple watchers. /// </summary> public class AssemblyWatcher { private FileSystemWatcher[] fileWatcher; private FileInfo[] fileInfo; protected Timer timer; protected string changedAssemblyPath; public delegate void AssemblyChangedHandler(String fullPath); public event AssemblyChangedHandler AssemblyChangedEvent; public AssemblyWatcher(int delay, string assemblyFileName) : this(delay, new string[] {assemblyFileName}) { } public AssemblyWatcher(int delay, IList assemblies) { fileInfo = new FileInfo[assemblies.Count]; fileWatcher = new FileSystemWatcher[assemblies.Count]; for (int i = 0; i < assemblies.Count; i++) { fileInfo[i] = new FileInfo((string) assemblies[i]); fileWatcher[i] = new FileSystemWatcher(); fileWatcher[i].Path = fileInfo[i].DirectoryName; fileWatcher[i].Filter = fileInfo[i].Name; fileWatcher[i].NotifyFilter = NotifyFilters.Size | NotifyFilters.LastWrite; fileWatcher[i].Changed += new FileSystemEventHandler(OnChanged); fileWatcher[i].EnableRaisingEvents = false; } timer = new Timer(delay); timer.AutoReset = false; timer.Enabled = false; timer.Elapsed += new ElapsedEventHandler(OnTimer); } public FileInfo GetFileInfo(int index) { return fileInfo[index]; } public void Start() { EnableWatchers(true); } public void Stop() { EnableWatchers(false); } private void EnableWatchers(bool enable) { foreach (FileSystemWatcher watcher in fileWatcher) watcher.EnableRaisingEvents = enable; } protected void OnTimer(Object source, ElapsedEventArgs e) { lock (this) { PublishEvent(); timer.Enabled = false; } } protected void OnChanged(object source, FileSystemEventArgs e) { changedAssemblyPath = e.FullPath; if (timer != null) { lock (this) { if (!timer.Enabled) timer.Enabled = true; timer.Start(); } } else { PublishEvent(); } } protected void PublishEvent() { if (AssemblyChangedEvent != null) AssemblyChangedEvent(changedAssemblyPath); } } } --- NEW FILE: TestResult.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; /// <summary> /// Summary description for TestResult. /// </summary> /// [Serializable] public class TestResult : AbstractTestResult { protected string _category = ""; protected string _description = ""; protected TestType _testType = TestType.Unit; public TestResult(Test t) { this.Name = t.Name; this.Category = t.Category; this.TestType = t.TestType; } public TestType TestType { get{return this._testType;} set{this._testType = value;} } /// <summary> /// Gets or sets the category. /// </summary> /// <value></value> public string Category { get { return this._category; } set { this._category = value; } } /// <summary> /// Gets or sets the description. /// </summary> /// <value></value> public string Description { get{ return this._description;} set{ this._description = value;} } public double GetAvgOpsPerSecond() { double i = 0; foreach (TestIteration ti in this._iterations) { i += ti.GetOpsPerSecond(); } double avg = i/this._iterations.Count; return avg; } public long GetAvgMemoryUsed() { long i = 0; foreach (TestIteration ti in this._iterations) { i += ti.MemoryUsed; } long avg = i/this._iterations.Count; return avg; } } } --- NEW FILE: TestHelper.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; /// <summary> /// Summary description for TestHelper. /// </summary> /// [Serializable] public class TestHelper : BaseTestHelper { private string _test = ""; public string Test { get { return this._test; } set { this._test = value; } } } } --- NEW FILE: TestAssemblyResult.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion namespace Adapdev.UnitTest.Core { using System; /// <summary> /// Summary description for TestAssemblyResult. /// </summary> /// [Serializable] public class TestAssemblyResult : AbstractTestResult { protected string _assemblyName = ""; protected string _assemblyFullName = ""; protected string _location = null; protected DateTime _runTime = DateTime.Now; public TestAssemblyResult(TestAssembly ta) { this.Name = ta.Name; } public string Location { get { return this._location; } set { this._location = value; } } public string AssemblyName { get { return this._assemblyName; } set { this._assemblyName = value; } } public string AssemblyFullName { get { return this._assemblyFullName; } set { this._assemblyFullName = value; } } public DateTime RunTime { get{return this._runTime;} set{this._runTime = value;} } } } --- NEW FILE: TestEventDispatcher.cs --- #region Copyright / License Information /* Author: Sean McCormack ================================================ Copyright ================================================ Copyright (c) 2004 Adapdev Technologies, LLC ================================================ License ================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ Change History ================================================ III MM/DD/YYYY Change */ #endregion using Adapdev; namespace Adapdev.UnitTest.Core { public delegate void TestIterationStartedEventHandler(object sender, TestEventArgs e); public delegate void TestIterationCompletedEventHandler(object sender, TestIterationEventArgs e); public delegate void TestCompletedEventHandler(object sender, TestResultEventArgs e); public delegate void TestStartedEventHandler(object sender, TestEventArgs e); public delegate void TestFixtureCompletedEventHandler(object sender, TestFixtureResultEventArgs e); public delegate void TestFixtureStartedEventHandler(object sender, TestFixtureEventArgs e); public delegate void TestFixtureIterationStartedEventHandler(object sender, TestFixtureEventArgs e); public delegate void TestFixtureIterationCompletedEventHandler(object sender, TestFixtureIterationEventArgs e); public delegate void TestAssemblyIterationCompletedEventHandler(object sender, TestAssemblyIterationEventArgs e); public delegate void TestAssemblyIterationStartedEventHandler(object sender, TestAssemblyEventArgs e); public delegate void TestAssemblyCompletedEventHandler(object sender, TestAssemblyResultEventArgs e); public delegate void TestAssemblyStartedEventHandler(object sender, TestAssemblyEventArgs e); public delegate void ErrorEventHandler(object sender, ErrorEventArgs e); public delegate void BaseTestHelperStartedEventHandler(object sender, BaseTestHelperEventArgs e); public delegate void TestSuiteCompletedEventHandler(object sender, TestAssemblyResult[] tar); /// <summary> /// Summary description for TestEventDispatcher. /// </summary> public class TestEventDispatcher : LongLivingMarshalByRefObject { public TestEventDispatcher() { } public event TestIterationCompletedEventHandler TestIterationCompleted; public event TestIterationStartedEventHandler TestIterationStarted; public event TestCompletedEventHandler TestCompleted; public event TestStartedEventHandler TestStarted; public event TestFixtureIterationStartedEventHandler TestFixtureIterationStarted; public event TestFixtureIterationCompletedEventHandler TestFixtureIterationCompleted; public event TestFixtureCompletedEventHandler TestFixtureCompleted; public event TestFixtureStartedEventHandler TestFixtureStarted; public event TestAssemblyIterationStartedEventHandler TestAssemblyIterationStarted; public event TestAssemblyIterationCompletedEventHandler TestAssemblyIterationCompleted; public event TestAssemblyCompletedEventHandler TestAssemblyCompleted; public event TestAssemblyStartedEventHandler TestAssemblyStarted; public event TestSuiteCompletedEventHandler TestSuiteCompleted; public event ErrorEventHandler ErrorOccured; public event BaseTestHelperStartedEventHandler BaseTestHelperStarted; public virtual void OnTestIterationStarted(TestEventArgs e) { if (TestIterationStarted != null) { //Invokes the delegates. TestIterationStarted(this, e); } } public virtual void OnTestIterationCompleted(TestIterationEventArgs e) { if (TestIterationCompleted != null) { //Invokes the delegates. TestIterationCompleted(this, e); } } public virtual void OnTestFixtureIterationStarted(TestFixtureEventArgs e) { if (TestFixtureIterationStarted != null) { //Invokes the delegates. TestFixtureIterationStarted(this, e); } } public virtual void OnTestFixtureIterationCompleted(TestFixtureIterationEventArgs e) { if (TestFixtureIterationCompleted != null) { //Invokes the delegates. TestFixtureIterationCompleted(this, e); } } public virtual void OnTestAssemblyIterationStarted(TestAssemblyEventArgs e) { if (TestAssemblyIterationStarted != null) { //Invokes the delegates. TestAssemblyIterationStarted(this, e); } } public virtual void OnTestAssemblyIterationCompleted(TestAssemblyIterationEventArgs e) { if (TestAssemblyIterationCompleted != null) { //Invokes the delegates. TestAssemblyIterationCompleted(this, e); } } public virtual void OnTestCompleted(TestResultEventArgs e) { if (TestCompleted != null) { //Invokes the delegates. TestCompleted(this, e); } } public virtual void OnTestFixtureCompleted(TestFixtureResultEventArgs e) { if (TestFixtureCompleted != null) { //Invokes the delegates. TestFixtureCompleted(this, e); } } public virtual void OnTestAssemblyCompleted(TestAssemblyResultEventArgs e) { if (TestAssemblyCompleted != null) { //Invokes the delegates. TestAssemblyCompleted(this, e); } } public... [truncated message content] |