1
1
using Xunit ;
2
2
using Infrastructure . AssemblyLoader ;
3
+ using Infrastructure . Module ;
3
4
using System ;
4
5
using System . Reflection ;
5
6
using System . IO ;
7
+ using System . Linq ;
6
8
7
9
namespace Module . Tests
8
10
{
9
11
public class BasicModuleLoaderTests
10
12
{
11
- /// TODO: add SampleModulesRefs.targets so that when Module.Tests projects builds, sample modules copied to test project Modules folder
12
- private const string assemblyPath = "/Users/Marvs/source/accountgo/test/Module.Tests/Modules/" ;
13
13
[ Fact ]
14
14
public void LoadNetCoreApp21ModuleProject ( )
15
15
{
16
16
//Given
17
- string path = assemblyPath + "SampleNetStandard20/netstandard2.0/SampleNetStandard20.dll" ;
17
+ Constants . CodeBaseRootPath = GetExecutingDirectorybyAppDomain ( ) ;
18
+ var path = Path . Combine ( Constants . CodeBaseRootPath , "SampleNetStandard20.dll" ) ;
18
19
var assembly = new CustomAssemblyLoadContext ( ) . LoadFromAssemblyPath ( path ) ;
19
20
var type = assembly . GetType ( "SampleNetStandard20.Class1" ) ;
20
21
//When
@@ -24,6 +25,26 @@ public void LoadNetCoreApp21ModuleProject()
24
25
Assert . Equal ( "Hello, World!" , returnValue ) ;
25
26
}
26
27
28
+ [ Fact ]
29
+ public void GetListOfModulesInJsonFile ( )
30
+ {
31
+ //Given
32
+ Constants . CodeBaseRootPath = GetExecutingDirectorybyAppDomain ( ) ;
33
+ AssemblyLoaderManager loader = new AssemblyLoaderManager ( ) ;
34
+ //When
35
+ var ( modules , plugins ) = loader . GetAssembliesToLoad ( ) ;
36
+ //Then
37
+ Assert . NotEmpty ( modules ) ;
38
+ }
39
+
40
+ [ Fact ]
41
+ public void PrintSolutionVariables ( )
42
+ {
43
+ Console . WriteLine ( GetAssemblyPathByCodeBase ( ) ) ;
44
+ Console . WriteLine ( GetExecutingDirectorybyAppDomain ( ) ) ;
45
+ Console . WriteLine ( GetExecutingDirectoryByAssemblyLocation ( ) ) ;
46
+ }
47
+
27
48
private string GetAssemblyPathByCodeBase ( )
28
49
{
29
50
string codeBase = Assembly . GetExecutingAssembly ( ) . CodeBase ;
@@ -39,7 +60,7 @@ private string GetExecutingDirectorybyAppDomain()
39
60
40
61
private string GetExecutingDirectoryByAssemblyLocation ( )
41
62
{
42
- string path = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
63
+ string path = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
43
64
return path ; // /Users/Marvs/source/accountgo/test/Module.Tests/bin/Debug/netcoreapp2.1
44
65
}
45
66
}
0 commit comments