27
27
28
28
using Moq ;
29
29
30
- #nullable disable
31
-
32
30
namespace TestPlatform . TestHostProvider . UnitTests . Hosting ;
33
31
34
32
[ TestClass ]
@@ -37,35 +35,21 @@ public class DotnetTestHostManagerTests
37
35
private const string DefaultDotnetPath = "c:\\ tmp\\ dotnet.exe" ;
38
36
39
37
private readonly Mock < ITestHostLauncher > _mockTestHostLauncher ;
40
-
41
38
private readonly Mock < IProcessHelper > _mockProcessHelper ;
42
-
43
39
private readonly Mock < IFileHelper > _mockFileHelper ;
44
-
45
40
private readonly Mock < IWindowsRegistryHelper > _mockWindowsRegistry ;
46
-
47
41
private readonly Mock < IMessageLogger > _mockMessageLogger ;
48
-
49
42
private readonly Mock < IEnvironment > _mockEnvironment ;
50
-
51
43
private readonly Mock < IRunSettingsHelper > _mockRunsettingHelper ;
52
-
53
44
private readonly TestRunnerConnectionInfo _defaultConnectionInfo ;
54
-
55
45
private readonly string [ ] _testSource = { "test.dll" } ;
56
-
57
46
private readonly string _defaultTestHostPath ;
58
-
59
47
private readonly TestProcessStartInfo _defaultTestProcessStartInfo ;
60
-
61
48
private readonly TestableDotnetTestHostManager _dotnetHostManager ;
62
-
63
49
private readonly Mock < IEnvironmentVariableHelper > _mockEnvironmentVariable ;
64
50
65
- private string _errorMessage ;
66
-
51
+ private string ? _errorMessage ;
67
52
private int _exitCode ;
68
-
69
53
private int _testHostId ;
70
54
71
55
private readonly string _temp = Path . GetTempPath ( ) ;
@@ -102,7 +86,7 @@ public DotnetTestHostManagerTests()
102
86
_mockProcessHelper . Setup ( ph => ph . GetCurrentProcessFileName ( ) ) . Returns ( DefaultDotnetPath ) ;
103
87
_mockProcessHelper . Setup ( ph => ph . GetTestEngineDirectory ( ) ) . Returns ( DefaultDotnetPath ) ;
104
88
_mockProcessHelper . Setup ( ph => ph . GetCurrentProcessArchitecture ( ) ) . Returns ( PlatformArchitecture . X64 ) ;
105
- _mockEnvironmentVariable . Setup ( ev => ev . GetEnvironmentVariable ( It . IsAny < string > ( ) ) ) . Returns ( Path . GetDirectoryName ( DefaultDotnetPath ) ) ;
89
+ _mockEnvironmentVariable . Setup ( ev => ev . GetEnvironmentVariable ( It . IsAny < string > ( ) ) ) . Returns ( Path . GetDirectoryName ( DefaultDotnetPath ) ! ) ;
106
90
_mockFileHelper . Setup ( ph => ph . Exists ( _defaultTestHostPath ) ) . Returns ( true ) ;
107
91
_mockFileHelper . Setup ( ph => ph . Exists ( DefaultDotnetPath ) ) . Returns ( true ) ;
108
92
@@ -514,7 +498,7 @@ public void GetTestHostProcessStartInfoShouldThrowExceptionWhenDotnetIsNotInstal
514
498
dotnetExeName = "dotnet" ;
515
499
}
516
500
517
- var paths = Environment . GetEnvironmentVariable ( "PATH" ) . Split ( separator ) ;
501
+ var paths = Environment . GetEnvironmentVariable ( "PATH" ) ! . Split ( separator ) ;
518
502
519
503
foreach ( string path in paths )
520
504
{
@@ -629,7 +613,7 @@ public void GetTestHostProcessStartInfoShouldIncludeTestHostPathNextToTestRunner
629
613
string testhostNextToTestDll = Path . Combine ( _temp , "testhost.dll" ) ;
630
614
_mockFileHelper . Setup ( ph => ph . Exists ( testhostNextToTestDll ) ) . Returns ( false ) ;
631
615
632
- var here = Path . GetDirectoryName ( Assembly . GetEntryAssembly ( ) . Location ) ;
616
+ var here = Path . GetDirectoryName ( Assembly . GetEntryAssembly ( ) ! . Location ) ! ;
633
617
var expectedTestHostPath = Path . Combine ( here , "testhost.dll" ) ;
634
618
_mockFileHelper . Setup ( ph => ph . Exists ( expectedTestHostPath ) ) . Returns ( true ) ;
635
619
@@ -671,7 +655,7 @@ public void GetTestHostProcessStartInfoShouldIncludeTestHostPathNextToTestRunner
671
655
string testhostNextToTestDll = Path . Combine ( _temp , "testhost.dll" ) ;
672
656
_mockFileHelper . Setup ( ph => ph . Exists ( testhostNextToTestDll ) ) . Returns ( false ) ;
673
657
674
- var here = Path . GetDirectoryName ( Assembly . GetEntryAssembly ( ) . Location ) ;
658
+ var here = Path . GetDirectoryName ( Assembly . GetEntryAssembly ( ) ! . Location ) ! ;
675
659
var testhostNextToRunner = Path . Combine ( here , "testhost.dll" ) ;
676
660
_mockFileHelper . Setup ( ph => ph . Exists ( testhostNextToRunner ) ) . Returns ( true ) ;
677
661
@@ -1003,21 +987,21 @@ public async Task CleanTestHostAsyncShouldNotThrowIfTestHostIsNotStarted()
1003
987
Assert . IsTrue ( isVerified ) ;
1004
988
}
1005
989
1006
- private void DotnetHostManagerExitCodeTesterHostExited ( object sender , HostProviderEventArgs e )
990
+ private void DotnetHostManagerExitCodeTesterHostExited ( object ? sender , HostProviderEventArgs e )
1007
991
{
1008
992
_errorMessage = e . Data . TrimEnd ( Environment . NewLine . ToCharArray ( ) ) ;
1009
993
_exitCode = e . ErrroCode ;
1010
994
}
1011
995
1012
- private void DotnetHostManagerHostExited ( object sender , HostProviderEventArgs e )
996
+ private void DotnetHostManagerHostExited ( object ? sender , HostProviderEventArgs e )
1013
997
{
1014
998
if ( e . ErrroCode != 0 )
1015
999
{
1016
1000
_errorMessage = e . Data . TrimEnd ( Environment . NewLine . ToCharArray ( ) ) ;
1017
1001
}
1018
1002
}
1019
1003
1020
- private void DotnetHostManagerHostLaunched ( object sender , HostProviderEventArgs e )
1004
+ private void DotnetHostManagerHostLaunched ( object ? sender , HostProviderEventArgs e )
1021
1005
{
1022
1006
_testHostId = e . ProcessId ;
1023
1007
}
0 commit comments