-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathNUnit3DriverFactory.cs
More file actions
53 lines (48 loc) · 2.21 KB
/
Copy pathNUnit3DriverFactory.cs
File metadata and controls
53 lines (48 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt
using System;
using System.Reflection;
using NUnit.Engine.Extensibility;
namespace NUnit.Engine.Drivers
{
public class NUnit3DriverFactory : IDriverFactory
{
internal const string NUNIT_FRAMEWORK = "nunit.framework";
private static readonly Logger log = InternalTrace.GetLogger(typeof(NUnit3DriverFactory));
/// <summary>
/// Gets a flag indicating whether a given assembly name and version
/// represent a test framework supported by this factory.
/// </summary>
/// <param name="reference">An AssemblyName referring to the possible test framework.</param>
public bool IsSupportedTestFramework(AssemblyName reference)
{
return NUNIT_FRAMEWORK.Equals(reference.Name, StringComparison.OrdinalIgnoreCase) && reference.Version?.Major is 3 or 4;
}
#if NETFRAMEWORK
/// <summary>
/// Gets a driver for a given test framework.
/// </summary>
/// <param name="domain">The domain in which the assembly will be loaded</param>
/// <param name="reference">An AssemblyName referring to the test framework.</param>
/// <returns>An IFrameworkDriver</returns>
public IFrameworkDriver GetDriver(AppDomain domain, string id, AssemblyName reference)
{
Guard.ArgumentNotNullOrEmpty(id);
Guard.ArgumentValid(IsSupportedTestFramework(reference), "Invalid framework", nameof(reference));
log.Info("Using NUnitFrameworkDriver");
return new NUnitFrameworkDriver(domain, id, reference);
}
#else
/// <summary>
/// Gets a driver for a given test framework.
/// </summary>
/// <param name="reference">An AssemblyName referring to the test framework.</param>
public IFrameworkDriver GetDriver(string id, AssemblyName reference)
{
Guard.ArgumentNotNullOrEmpty(id);
Guard.ArgumentValid(IsSupportedTestFramework(reference), "Invalid framework", nameof(reference));
log.Info("Using NUnitFrameworkDriver");
return new NUnitFrameworkDriver(id, reference);
}
#endif
}
}