|
10 | 10 | using NUnit.Engine.Internal;
|
11 | 11 | using NSubstitute;
|
12 | 12 | using NUnit.Engine.Internal.FileSystemAccess;
|
| 13 | +using System.Diagnostics; |
13 | 14 |
|
14 | 15 | namespace NUnit.Engine.Services.Tests
|
15 | 16 | {
|
@@ -57,9 +58,12 @@ public void CreateExtensionManager()
|
57 | 58 | // Find actual extension points.
|
58 | 59 | _extensionManager.FindExtensionPoints(typeof(CoreEngine).Assembly);
|
59 | 60 | _extensionManager.FindExtensionPoints(typeof(ITestEngine).Assembly);
|
60 |
| - |
61 |
| - // Find dummy extensions in this test assembly. |
62 |
| - _extensionManager.FindExtensionsInAssembly(new ExtensionAssembly(GetType().Assembly.Location, false)); |
| 61 | + // Find extensions. |
| 62 | +#if NETCOREAPP |
| 63 | + _extensionManager.FindExtensionsInAssembly(FakeExtensions("netstandard2.0")); |
| 64 | +#else |
| 65 | + _extensionManager.FindExtensionsInAssembly(FakeExtensions("net462")); |
| 66 | +#endif |
63 | 67 | }
|
64 | 68 |
|
65 | 69 | [Test]
|
@@ -161,21 +165,39 @@ public void SkipsGracefullyLoadingOtherFrameworkExtensionAssembly()
|
161 | 165 | Assert.That(() => service.FindExtensionsInAssembly(extensionAssembly), Throws.Nothing);
|
162 | 166 | }
|
163 | 167 |
|
164 |
| - [TestCaseSource(nameof(ValidCombos))] |
| 168 | +#if NETCOREAPP |
| 169 | + [TestCase("netstandard2.0", ExpectedResult = true)] |
| 170 | + [TestCase("net462", ExpectedResult = false)] |
| 171 | + //[TestCase("net20", ExpectedResult = false)] |
| 172 | +#elif NET40_OR_GREATER |
| 173 | + [TestCase("netstandard2.0", ExpectedResult = false)] |
| 174 | + [TestCase("net462", ExpectedResult = true)] |
| 175 | + //[TestCase("net20", ExpectedResult = true)] |
| 176 | +#else |
| 177 | + [TestCase("netstandard2.0", ExpectedResult = false)] |
| 178 | + [TestCase("net462", ExpectedResult = false)] |
| 179 | + //[TestCase("net20", ExpectedResult = true)] |
| 180 | +#endif |
| 181 | + public bool LoadTargetFramework(string tfm) |
| 182 | + { |
| 183 | + return _extensionManager.CanLoadTargetFramework(THIS_ASSEMBLY, FakeExtensions(tfm)); |
| 184 | + } |
| 185 | + |
| 186 | + //[TestCaseSource(nameof(ValidCombos))] |
165 | 187 | public void ValidTargetFrameworkCombinations(FrameworkCombo combo)
|
166 | 188 | {
|
167 | 189 | Assert.That(() => _extensionManager.CanLoadTargetFramework(combo.RunnerAssembly, combo.ExtensionAssembly),
|
168 | 190 | Is.True);
|
169 | 191 | }
|
170 | 192 |
|
171 |
| - [TestCaseSource(nameof(InvalidTargetFrameworkCombos))] |
| 193 | + //[TestCaseSource(nameof(InvalidTargetFrameworkCombos))] |
172 | 194 | public void InvalidTargetFrameworkCombinations(FrameworkCombo combo)
|
173 | 195 | {
|
174 | 196 | Assert.That(() => _extensionManager.CanLoadTargetFramework(combo.RunnerAssembly, combo.ExtensionAssembly),
|
175 | 197 | Is.False);
|
176 | 198 | }
|
177 | 199 |
|
178 |
| - [TestCaseSource(nameof(InvalidRunnerCombos))] |
| 200 | + //[TestCaseSource(nameof(InvalidRunnerCombos))] |
179 | 201 | public void InvalidRunnerTargetFrameworkCombinations(FrameworkCombo combo)
|
180 | 202 | {
|
181 | 203 | var ex = Assert.Catch(() => _extensionManager.CanLoadTargetFramework(combo.RunnerAssembly, combo.ExtensionAssembly));
|
@@ -275,5 +297,23 @@ private static string GetSiblingDirectory(string dir)
|
275 | 297 | var file = new FileInfo(typeof(ExtensionManagerTests).Assembly.Location);
|
276 | 298 | return Path.Combine(file.Directory.Parent.FullName, dir);
|
277 | 299 | }
|
| 300 | + |
| 301 | + private static readonly Assembly THIS_ASSEMBLY = typeof(ExtensionManagerTests).Assembly; |
| 302 | + private static readonly string THIS_ASSEMBLY_DIRECTORY = Path.GetDirectoryName(THIS_ASSEMBLY.Location); |
| 303 | + private const string FAKE_EXTENSIONS_FILENAME = "FakeExtensions.dll"; |
| 304 | + private static readonly string FAKE_EXTENSIONS_PARENT_DIRECTORY = |
| 305 | + Path.Combine(new DirectoryInfo(THIS_ASSEMBLY_DIRECTORY).Parent.FullName, "fakes"); |
| 306 | + |
| 307 | + /// <summary> |
| 308 | + /// Returns an ExtensionAssembly referring to a particular build of the fake test extensions |
| 309 | + /// assembly based on the argument provided. |
| 310 | + /// </summary> |
| 311 | + /// <param name="tfm">A test framework moniker. Must be one for which the fake extensions are built.</param> |
| 312 | + /// <returns></returns> |
| 313 | + private static ExtensionAssembly FakeExtensions(string tfm) |
| 314 | + { |
| 315 | + return new ExtensionAssembly( |
| 316 | + Path.Combine(FAKE_EXTENSIONS_PARENT_DIRECTORY, Path.Combine(tfm, FAKE_EXTENSIONS_FILENAME)), false); |
| 317 | + } |
278 | 318 | }
|
279 | 319 | }
|
0 commit comments