88using System . IO ;
99using System . Reflection ;
1010using System . Collections . Generic ;
11+ using System . Net ;
1112
1213namespace NUnit . Extensibility
1314{
@@ -18,9 +19,11 @@ public class ExtensionManagerTests
1819 private static readonly string THIS_ASSEMBLY_DIRECTORY = Path . GetDirectoryName ( THIS_ASSEMBLY . Location ) ! ;
1920 private const string FAKE_EXTENSIONS_FILENAME = "FakeExtensions.dll" ;
2021 private static readonly string FAKE_EXTENSIONS_PARENT_DIRECTORY =
21- Path . Combine ( new DirectoryInfo ( THIS_ASSEMBLY_DIRECTORY ) . Parent ! . FullName , "fakesv2" ) ;
22- private static readonly string FAKE_EXTENSIONS_SOURCE_DIRECTORY =
23- Path . Combine ( new DirectoryInfo ( THIS_ASSEMBLY_DIRECTORY ) . Parent ! . Parent ! . Parent ! . FullName , "src/TestData/FakeExtensions" ) ;
22+ #if NETFRAMEWORK
23+ Path . Combine ( new DirectoryInfo ( THIS_ASSEMBLY_DIRECTORY ) . Parent ! . FullName , "fakesv2/net462" ) ;
24+ #else
25+ Path . Combine ( new DirectoryInfo ( THIS_ASSEMBLY_DIRECTORY ) . Parent ! . FullName , "fakesv2/netstandard2.0" ) ;
26+ #endif
2427
2528 private const string FAKE_AGENT_LAUNCHER_EXTENSION = "NUnit.Engine.Fakes.FakeAgentLauncherExtension" ;
2629 private const string FAKE_FRAMEWORK_DRIVER_EXTENSION = "NUnit.Engine.Fakes.FakeFrameworkDriverExtension" ;
@@ -30,6 +33,7 @@ public class ExtensionManagerTests
3033 private const string FAKE_SERVICE_EXTENSION = "NUnit.Engine.Fakes.FakeServiceExtension" ;
3134 private const string FAKE_DISABLED_EXTENSION = "NUnit.Engine.Fakes.FakeDisabledExtension" ;
3235 private const string FAKE_NUNIT_V2_DRIVER_EXTENSION = "NUnit.Engine.Fakes.V2DriverExtension" ;
36+ private const string FAKE_EXTENSION_WITH_NO_EXTENSION_POINT = "NUnit.Engine.Fakes.FakeExtension_NoExtensionPointFound" ;
3337
3438 private readonly string [ ] KnownExtensions =
3539 {
@@ -39,8 +43,9 @@ public class ExtensionManagerTests
3943 FAKE_RESULT_WRITER_EXTENSION ,
4044 FAKE_EVENT_LISTENER_EXTENSION ,
4145 FAKE_SERVICE_EXTENSION ,
42- FAKE_DISABLED_EXTENSION
43- //FAKE_NUNIT_V2_DRIVER_EXTENSION
46+ FAKE_DISABLED_EXTENSION ,
47+ //FAKE_NUNIT_V2_DRIVER_EXTENSION,
48+ FAKE_EXTENSION_WITH_NO_EXTENSION_POINT
4449 } ;
4550
4651 private ExtensionManager _extensionManager ;
@@ -94,7 +99,7 @@ public void CreateExtensionManager()
9499 _extensionManager . FindExtensionPoints ( typeof ( ITestEngine ) . Assembly ) ;
95100
96101 // Find Fake Extensions using alternate start directory
97- _extensionManager . FindExtensionAssemblies ( FAKE_EXTENSIONS_SOURCE_DIRECTORY ) ;
102+ _extensionManager . FindExtensionAssemblies ( FAKE_EXTENSIONS_PARENT_DIRECTORY ) ;
98103 _extensionManager . LoadExtensions ( ) ;
99104 }
100105
@@ -121,6 +126,18 @@ public void AllExtensionsUseTheLatestVersion()
121126 Assert . That ( node . AssemblyVersion . ToString ( ) , Is . EqualTo ( "2.0.0.0" ) ) ;
122127 }
123128
129+ [ Test ]
130+ public void AllExtensionsHaveCorrectStatus ( )
131+ {
132+ foreach ( var node in _extensionManager . Extensions )
133+ {
134+ var expectedStatus = node . TypeName == FAKE_EXTENSION_WITH_NO_EXTENSION_POINT
135+ ? ExtensionStatus . Unknown
136+ : ExtensionStatus . Unloaded ;
137+ Assert . That ( node . Status , Is . EqualTo ( expectedStatus ) ) ;
138+ }
139+ }
140+
124141 [ Test ]
125142 public void AllKnownExtensionsAreEnabledAsRequired ( )
126143 {
@@ -216,20 +233,20 @@ public void SkipsGracefullyLoadingOtherFrameworkExtensionAssembly()
216233
217234#if NETCOREAPP
218235 [ TestCase ( "netstandard2.0" , ExpectedResult = true ) ]
219- [ TestCase ( "net462" , ExpectedResult = false ) ]
236+ // [TestCase("net462", ExpectedResult = false)]
220237 //[TestCase("net20", ExpectedResult = false)]
221238#elif NET40_OR_GREATER
222- [ TestCase ( "netstandard2.0" , ExpectedResult = false ) ]
239+ // [TestCase("netstandard2.0", ExpectedResult = false)]
223240 [ TestCase ( "net462" , ExpectedResult = true ) ]
224241 //[TestCase("net20", ExpectedResult = true)]
225242#else
226- [ TestCase ( "netstandard2.0" , ExpectedResult = false ) ]
227- [ TestCase ( "net462" , ExpectedResult = false ) ]
243+ // [TestCase("netstandard2.0", ExpectedResult = false)]
244+ // [TestCase("net462", ExpectedResult = false)]
228245 //[TestCase("net20", ExpectedResult = true)]
229246#endif
230247 public bool LoadTargetFramework ( string tfm )
231248 {
232- return _extensionManager . CanLoadTargetFramework ( THIS_ASSEMBLY , FakeExtensions ( tfm ) ) ;
249+ return _extensionManager . CanLoadTargetFramework ( THIS_ASSEMBLY , FakeExtensions ( ) ) ;
233250 }
234251
235252 //[TestCaseSource(nameof(ValidCombos))]
@@ -351,10 +368,10 @@ private static string GetSiblingDirectory(string dir)
351368 /// assembly based on the argument provided.
352369 /// </summary>
353370 /// <param name="tfm">A test framework moniker. Must be one for which the fake extensions are built.</param>
354- private static ExtensionAssembly FakeExtensions ( string tfm )
371+ private static ExtensionAssembly FakeExtensions ( )
355372 {
356373 return new ExtensionAssembly (
357- Path . Combine ( FAKE_EXTENSIONS_PARENT_DIRECTORY , Path . Combine ( tfm , FAKE_EXTENSIONS_FILENAME ) ) , false ) ;
374+ Path . Combine ( FAKE_EXTENSIONS_PARENT_DIRECTORY , FAKE_EXTENSIONS_FILENAME ) , false ) ;
358375 }
359376 }
360377}
0 commit comments