retag
[mcs.git] / nunit24 / ClientUtilities / util / MultipleTestDomainRunner.cs
blobddd9b0d90b582a79c95635930f480c5da9337f08
1 // ****************************************************************
2 // Copyright 2007, Charlie Poole
3 // This is free software licensed under the NUnit license. You may
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4
5 // ****************************************************************
7 using System;
8 using System.Collections;
9 using NUnit.Core;
11 namespace NUnit.Util
13 /// <summary>
14 /// Summary description for MultipleTestDomainRunner.
15 /// </summary>
16 public class MultipleTestDomainRunner : AggregatingTestRunner
18 #region Constructors
19 public MultipleTestDomainRunner() : base( 0 ) { }
21 public MultipleTestDomainRunner( int runnerID ) : base( runnerID ) { }
22 #endregion
24 #region Load Method Overrides
25 public override bool Load(TestPackage package)
27 this.projectName = package.FullName;
28 this.testName.FullName = this.testName.Name = projectName;
29 runners = new ArrayList();
31 int nfound = 0;
32 int index = 0;
34 string targetAssemblyName = null;
35 if( package.TestName != null && package.Assemblies.Contains( package.TestName ) )
37 targetAssemblyName = package.TestName;
38 package.TestName = null;
41 foreach( string assembly in package.Assemblies )
43 if ( targetAssemblyName == null || targetAssemblyName == assembly )
45 TestDomain runner = new TestDomain( this.runnerID * 100 + index + 1 );
47 TestPackage p = new TestPackage( assembly );
48 p.AutoBinPath = package.AutoBinPath;
49 p.ConfigurationFile = package.ConfigurationFile;
50 p.BasePath = package.BasePath;
51 p.PrivateBinPath = package.PrivateBinPath;
52 p.TestName = package.TestName;
53 foreach( object key in package.Settings.Keys )
54 p.Settings[key] = package.Settings[key];
56 if ( package.TestName == null )
58 runners.Add( runner );
59 if ( runner.Load( p ) )
60 nfound++;
62 else if ( runner.Load( p ) )
64 runners.Add( runner );
65 nfound++;
70 if ( package.TestName == null && targetAssemblyName == null )
71 return nfound == package.Assemblies.Count;
72 else
73 return nfound > 0;
76 private void CreateRunners( int count )
78 runners = new ArrayList();
79 for( int index = 0; index < count; index++ )
81 TestDomain runner = new TestDomain( this.runnerID * 100 + index + 1 );
82 runners.Add( runner );
85 #endregion