Skip to content

Commit

Permalink
Changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
CharliePoole committed Mar 23, 2021
1 parent b26897d commit d34be71
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
38 changes: 14 additions & 24 deletions src/NUnitEngine/nunit.engine.api/TestPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public TestPackage(IList<string> testFiles)
private void InitializeSubPackages(IList<string> testFiles)
{
foreach (string testFile in testFiles)
SubPackages.Add(new TestPackage().Named(testFile));
AddSubPackage(testFile);
}

private static int _nextID = 0;
Expand Down Expand Up @@ -87,29 +87,6 @@ public string Name
/// </summary>
public string FullName { get; private set; }

/// <summary>
/// Fluent modifier intended for use with the default
/// constructor to assign a name to a package. This
/// should be used for creating subpackages as it is
/// the only way to assign a name to the package.
/// </summary>
/// <param name="fileName">The name or path of the file.</param>
/// <returns>The current instance.</returns>
/// <example>
/// var subpackage = new TestPackage().Named("test.dll");
/// </example>
/// <remarks>
/// This is provided for use by engine extensions that manipulate
/// the package structure as well as for internal use. For general
/// programmatic use of the engine, either of the constructors
/// will create a TestPackage in the form that the runner expects.
/// </remarks>
public TestPackage Named(string fileName)
{
FullName = Path.GetFullPath(fileName);
return this;
}

/// <summary>
/// Gets the list of SubPackages contained in this package
/// </summary>
Expand All @@ -132,6 +109,19 @@ public void AddSubPackage(TestPackage subPackage)
subPackage.Settings[key] = Settings[key];
}

/// <summary>
/// Add a subproject to the package, specifying its name. This is
/// the only way to add a named subpackage to the top-level package.
/// </summary>
/// <param name="packageName">The name of the subpackage to be added</param>
public TestPackage AddSubPackage(string packageName)
{
var subPackage = new TestPackage() { FullName = Path.GetFullPath(packageName) };
SubPackages.Add(subPackage);

return subPackage;
}

/// <summary>
/// Add a setting to a package and all of its subpackages.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ MultipleTestProcessRunner CreateRunner(int assemblyCount, int? maxAgents)
// Currently, we can get away with null entries here
var package = new TestPackage();
for (int i = 1; i <= assemblyCount; i++)
package.AddSubPackage(new TestPackage().Named($"test{i}.dll"));
package.AddSubPackage($"test{i}.dll");

if (maxAgents != null)
package.Settings[EnginePackageSettings.MaxAgents] = maxAgents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class DomainManagerTests
private DomainManager _domainManager;
// We use a named subpackage because that's what is normally
// used by the Domain Manager
private TestPackage _package = new TestPackage().Named(MockAssembly.AssemblyPath);
private TestPackage _package = new TestPackage(MockAssembly.AssemblyPath).SubPackages[0];

[SetUp]
public void CreateDomainManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void IProjectService.ExpandProjectPackage(TestPackage package)
if (_projects.ContainsKey(package.Name))
{
foreach (string assembly in _projects[package.Name])
package.AddSubPackage(new TestPackage().Named(assembly));
package.AddSubPackage(assembly);
}
}

Expand Down

0 comments on commit d34be71

Please sign in to comment.