@@ -1025,143 +1025,6 @@ public async Task CleanTestHostAsyncShouldNotThrowIfTestHostIsNotStarted()
1025
1025
Assert . IsTrue ( isVerified ) ;
1026
1026
}
1027
1027
1028
- [ TestMethod ]
1029
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT(x86)" , "DOTNET_ROOT(x86)" ) ]
1030
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT" , "DOTNET_ROOT" ) ]
1031
- public void ForwardDotnetRootEnvironmentVariableWhenTargetFrameworkIsLessThanNet6SetsCorrectEnvVariable ( string envVarName , string expectedForwaredName )
1032
- {
1033
- // Arrange
1034
- const string envVarValue = "c:\\ SomePath" ;
1035
- _mockEnvironmentVariable . Reset ( ) ;
1036
- _mockEnvironmentVariable . Setup ( x => x . GetEnvironmentVariable ( envVarName ) ) . Returns ( envVarValue ) ;
1037
- string runSettingsXml = """
1038
- <RunSettings>
1039
- <RunConfiguration>
1040
- <TargetFrameworkVersion>net5.0</TargetFrameworkVersion>
1041
- </RunConfiguration>
1042
- </RunSettings>
1043
- """ ;
1044
- _dotnetHostManager . Initialize ( _mockMessageLogger . Object , runSettingsXml ) ;
1045
-
1046
- var startInfo = new TestProcessStartInfo { EnvironmentVariables = new Dictionary < string , string ? > ( ) } ;
1047
- // Sanity check
1048
- Assert . AreEqual ( 0 , startInfo . EnvironmentVariables . Count ) ;
1049
-
1050
- // Act
1051
- _dotnetHostManager . ForwardDotnetRootEnvironmentVariable ( startInfo ) ;
1052
-
1053
- // Assert
1054
- Assert . AreEqual ( 1 , startInfo . EnvironmentVariables . Count ) ;
1055
- Assert . IsTrue ( startInfo . EnvironmentVariables . TryGetValue ( expectedForwaredName , out var actualEnvVarValue ) ) ;
1056
- Assert . AreEqual ( envVarValue , actualEnvVarValue ) ;
1057
- }
1058
-
1059
- [ TestMethod ]
1060
- [ DataRow ( "DOTNET_ROOT(x86)" , "net5.0" ) ]
1061
- [ DataRow ( "DOTNET_ROOT(x86)" , "net6.0" ) ]
1062
- [ DataRow ( "DOTNET_ROOT" , "net5.0" ) ]
1063
- [ DataRow ( "DOTNET_ROOT" , "net6.0" ) ]
1064
- [ DataRow ( "DOTNET_ROOT_X86" , "net5.0" ) ]
1065
- [ DataRow ( "DOTNET_ROOT_X86" , "net6.0" ) ]
1066
- [ DataRow ( "DOTNET_ROOT_X64" , "net5.0" ) ]
1067
- [ DataRow ( "DOTNET_ROOT_X64" , "net6.0" ) ]
1068
- [ DataRow ( "DOTNET_ROOT_ARM64" , "net5.0" ) ]
1069
- [ DataRow ( "DOTNET_ROOT_ARM64" , "net6.0" ) ]
1070
- public void ForwardDotnetRootEnvironmentVariableWhenIncorrectEnvVarDoesNothing ( string envVarName , string framework )
1071
- {
1072
- // Arrange
1073
- const string envVarValue = "c:\\ SomePath" ;
1074
- _mockEnvironmentVariable . Reset ( ) ;
1075
- _mockEnvironmentVariable . Setup ( x => x . GetEnvironmentVariable ( envVarName ) ) . Returns ( envVarValue ) ;
1076
- string runSettingsXml = $ """
1077
- <RunSettings>
1078
- <RunConfiguration>
1079
- <TargetFrameworkVersion>{ framework } </TargetFrameworkVersion>
1080
- </RunConfiguration>
1081
- </RunSettings>
1082
- """ ;
1083
- _dotnetHostManager . Initialize ( _mockMessageLogger . Object , runSettingsXml ) ;
1084
-
1085
- var startInfo = new TestProcessStartInfo { EnvironmentVariables = new Dictionary < string , string ? > ( ) } ;
1086
-
1087
- // Act
1088
- _dotnetHostManager . ForwardDotnetRootEnvironmentVariable ( startInfo ) ;
1089
-
1090
- // Assert
1091
- Assert . AreEqual ( 0 , startInfo . EnvironmentVariables . Count ) ;
1092
- }
1093
-
1094
- [ TestMethod ]
1095
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT(x86)" , PlatformArchitecture . X86 ) ]
1096
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT(x86)" , PlatformArchitecture . X64 ) ]
1097
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT" , PlatformArchitecture . X86 ) ]
1098
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT" , PlatformArchitecture . X64 ) ]
1099
- public void ForwardDotnetRootEnvironmentVariableWhenTargetFrameworkIsGreaterOrEqualsToNet6SetsCorrectEnvVariable ( string envVarName , PlatformArchitecture platformArchitecture )
1100
- {
1101
- // Arrange
1102
- const string envVarValue = "c:\\ SomePath" ;
1103
- _mockEnvironmentVariable . Reset ( ) ;
1104
- _mockEnvironmentVariable . Setup ( x => x . GetEnvironmentVariable ( envVarName ) ) . Returns ( envVarValue ) ;
1105
- _mockProcessHelper . Setup ( x => x . GetCurrentProcessArchitecture ( ) ) . Returns ( platformArchitecture ) ;
1106
- string runSettingsXml = """
1107
- <RunSettings>
1108
- <RunConfiguration>
1109
- <TargetFrameworkVersion>net6.0</TargetFrameworkVersion>
1110
- </RunConfiguration>
1111
- </RunSettings>
1112
- """ ;
1113
- _dotnetHostManager . Initialize ( _mockMessageLogger . Object , runSettingsXml ) ;
1114
-
1115
- var startInfo = new TestProcessStartInfo { EnvironmentVariables = new Dictionary < string , string ? > ( ) } ;
1116
- // Sanity check
1117
- Assert . AreEqual ( 0 , startInfo . EnvironmentVariables . Count ) ;
1118
-
1119
- // Act
1120
- _dotnetHostManager . ForwardDotnetRootEnvironmentVariable ( startInfo ) ;
1121
-
1122
- // Assert
1123
- Assert . AreEqual ( 1 , startInfo . EnvironmentVariables . Count ) ;
1124
- Assert . IsTrue ( startInfo . EnvironmentVariables . TryGetValue ( $ "DOTNET_ROOT_{ platformArchitecture . ToString ( ) . ToUpperInvariant ( ) } ", out var actualEnvVarValue ) ) ;
1125
- Assert . AreEqual ( envVarValue , actualEnvVarValue ) ;
1126
- }
1127
-
1128
- [ TestMethod ]
1129
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT(x86)" , PlatformArchitecture . X86 ) ]
1130
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT(x86)" , PlatformArchitecture . X64 ) ]
1131
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT(x86)" , PlatformArchitecture . ARM64 ) ]
1132
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT" , PlatformArchitecture . X86 ) ]
1133
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT" , PlatformArchitecture . X64 ) ]
1134
- [ DataRow ( "VSTEST_WINAPPHOST_DOTNET_ROOT" , PlatformArchitecture . ARM64 ) ]
1135
- public void ForwardDotnetRootEnvironmentVariableWhenTargetFrameworkIsGreaterOrEqualsToNet6DoesNotOverrideEnvVar ( string envVarName , PlatformArchitecture platformArchitecture )
1136
- {
1137
- // Arrange
1138
- const string expectedEnvVarValue = "c:\\ SomePath" ;
1139
- const string nonForwardedEnvVarValue = "C:\\ SomeOtherPath" ;
1140
- var expectedForwardedEnvVarName = $ "DOTNET_ROOT_{ platformArchitecture . ToString ( ) . ToUpperInvariant ( ) } ";
1141
- _mockEnvironmentVariable . Reset ( ) ;
1142
- _mockEnvironmentVariable . Setup ( x => x . GetEnvironmentVariable ( envVarName ) ) . Returns ( expectedEnvVarValue ) ;
1143
- _mockEnvironmentVariable . Setup ( x => x . GetEnvironmentVariable ( expectedForwardedEnvVarName ) ) . Returns ( nonForwardedEnvVarValue ) ;
1144
- _mockProcessHelper . Setup ( x => x . GetCurrentProcessArchitecture ( ) ) . Returns ( platformArchitecture ) ;
1145
- string runSettingsXml = """
1146
- <RunSettings>
1147
- <RunConfiguration>
1148
- <TargetFrameworkVersion>net6.0</TargetFrameworkVersion>
1149
- </RunConfiguration>
1150
- </RunSettings>
1151
- """ ;
1152
- _dotnetHostManager . Initialize ( _mockMessageLogger . Object , runSettingsXml ) ;
1153
-
1154
- var startInfo = new TestProcessStartInfo { EnvironmentVariables = new Dictionary < string , string ? > ( ) } ;
1155
- // Sanity check
1156
- Assert . AreEqual ( 0 , startInfo . EnvironmentVariables . Count ) ;
1157
-
1158
- // Act
1159
- _dotnetHostManager . ForwardDotnetRootEnvironmentVariable ( startInfo ) ;
1160
-
1161
- // Assert
1162
- Assert . AreEqual ( 0 , startInfo . EnvironmentVariables . Count ) ;
1163
- }
1164
-
1165
1028
private void DotnetHostManagerExitCodeTesterHostExited ( object ? sender , HostProviderEventArgs e )
1166
1029
{
1167
1030
_errorMessage = e . Data . TrimEnd ( Environment . NewLine . ToCharArray ( ) ) ;
0 commit comments