@@ -116,6 +116,81 @@ public void IsCorrectProfileLoaded_ConditionChange_ReturnsFalse()
116
116
Assert . False ( profileManager . IsCorrectProfileLoaded ( "java" ) ) ;
117
117
}
118
118
119
+ [ Fact ]
120
+ public void IsCorrectProfileLoaded_DifferentRuntimeNoProfile_ReturnsTrue ( )
121
+ {
122
+ var argumentList = new string [ ] { "-TestArg=1" } ;
123
+ var description = RpcWorkerConfigTestUtilities . GetTestDefaultWorkerDescription ( "java" , argumentList ) ;
124
+ var profiles = WorkerDescriptionProfileData ( "java" , description ) ;
125
+
126
+ _testEnvironment . SetEnvironmentVariable ( "APPLICATIONINSIGHTS_ENABLE_AGENT" , "true" ) ;
127
+
128
+ WorkerProfileManager profileManager = new ( _testLogger , _testEnvironment ) ;
129
+ profileManager . SetWorkerDescriptionProfiles ( profiles , "java" ) ;
130
+ profileManager . LoadWorkerDescriptionFromProfiles ( description , out var workerDescription ) ;
131
+
132
+ // Same profile should load as we didn't change any condition outcomes
133
+ Assert . True ( profileManager . IsCorrectProfileLoaded ( "java" ) ) ;
134
+
135
+ // Different runtime without profiles
136
+ Assert . True ( profileManager . IsCorrectProfileLoaded ( "dotnet" ) ) ;
137
+ }
138
+
139
+ [ Fact ]
140
+ public void IsCorrectProfileLoaded_DifferentRuntimeWithProfile_ReturnsTrue ( )
141
+ {
142
+ var argumentList = new string [ ] { "-TestArg=1" } ;
143
+ var description = RpcWorkerConfigTestUtilities . GetTestDefaultWorkerDescription ( "java" , argumentList ) ;
144
+ var profiles = WorkerDescriptionProfileData ( "java" , description ) ;
145
+
146
+ _testEnvironment . SetEnvironmentVariable ( "APPLICATIONINSIGHTS_ENABLE_AGENT" , "true" ) ;
147
+
148
+ WorkerProfileManager profileManager = new ( _testLogger , _testEnvironment ) ;
149
+ profileManager . SetWorkerDescriptionProfiles ( profiles , "java" ) ;
150
+ profileManager . LoadWorkerDescriptionFromProfiles ( description , out var javaWorkerDescription ) ;
151
+
152
+ var dotnetArgumentList = new string [ ] { "-TestArg=2" } ;
153
+ var dotnetDescription = RpcWorkerConfigTestUtilities . GetTestDefaultWorkerDescription ( "dotnet" , dotnetArgumentList ) ;
154
+ var dotnetProfiles = WorkerDescriptionProfileData ( "dotnet" , dotnetDescription ) ;
155
+
156
+ profileManager . SetWorkerDescriptionProfiles ( dotnetProfiles , "dotnet" ) ;
157
+ profileManager . LoadWorkerDescriptionFromProfiles ( dotnetDescription , out var dotnetWorkerDescription ) ;
158
+
159
+ // Same profile should load as we didn't change any condition outcomes
160
+ Assert . True ( profileManager . IsCorrectProfileLoaded ( "java" ) ) ;
161
+
162
+ // Different runtime also loads same profile as we didn't change any condition outcomes
163
+ Assert . True ( profileManager . IsCorrectProfileLoaded ( "dotnet" ) ) ;
164
+ }
165
+
166
+ [ Fact ]
167
+ public void IsCorrectProfileLoaded_DifferentRuntimeWithProfile_ReturnsFalse ( )
168
+ {
169
+ var argumentList = new string [ ] { "-TestArg=1" } ;
170
+ var description = RpcWorkerConfigTestUtilities . GetTestDefaultWorkerDescription ( "java" , argumentList ) ;
171
+ var profiles = WorkerDescriptionProfileData ( "java" , description ) ;
172
+
173
+ _testEnvironment . SetEnvironmentVariable ( "APPLICATIONINSIGHTS_ENABLE_AGENT" , "true" ) ;
174
+
175
+ WorkerProfileManager profileManager = new ( _testLogger , _testEnvironment ) ;
176
+ profileManager . SetWorkerDescriptionProfiles ( profiles , "java" ) ;
177
+ profileManager . LoadWorkerDescriptionFromProfiles ( description , out var javaWorkerDescription ) ;
178
+
179
+ var dotnetArgumentList = new string [ ] { "-TestArg=2" } ;
180
+ var dotnetDescription = RpcWorkerConfigTestUtilities . GetTestDefaultWorkerDescription ( "dotnet" , dotnetArgumentList ) ;
181
+ var dotnetProfiles = WorkerDescriptionProfileData ( "dotnet" , dotnetDescription ) ;
182
+
183
+ profileManager . SetWorkerDescriptionProfiles ( dotnetProfiles , "dotnet" ) ;
184
+ profileManager . LoadWorkerDescriptionFromProfiles ( dotnetDescription , out var dotnetWorkerDescription ) ;
185
+
186
+ // Same profile should load as we didn't change any condition outcomes
187
+ Assert . True ( profileManager . IsCorrectProfileLoaded ( "java" ) ) ;
188
+
189
+ // Changing the condition so a different profile evaluates to true
190
+ _testEnvironment . SetEnvironmentVariable ( "APPLICATIONINSIGHTS_ENABLE_AGENT" , "false" ) ;
191
+ Assert . False ( profileManager . IsCorrectProfileLoaded ( "dotnet" ) ) ;
192
+ }
193
+
119
194
public static List < WorkerDescriptionProfile > WorkerDescriptionProfileData ( string language , RpcWorkerDescription description )
120
195
{
121
196
var conditionLogger = new TestLogger ( "ConditionLogger" ) ;
0 commit comments