6
6
using Microsoft . Azure . WebJobs . Script . Workers ;
7
7
using Microsoft . Azure . WebJobs . Script . Workers . Profiles ;
8
8
using Microsoft . Azure . WebJobs . Script . Workers . Rpc ;
9
- using Microsoft . Extensions . Logging ;
10
9
using Newtonsoft . Json . Linq ;
11
10
using Xunit ;
12
11
13
12
namespace Microsoft . Azure . WebJobs . Script . Tests . Workers . Profiles
14
13
{
15
14
public class WorkerProfileManagerTests
16
15
{
17
- private static LoggerFactory _testLoggerFactory = new LoggerFactory ( ) ;
18
- private static TestEnvironment _testEnvironment = new TestEnvironment ( ) ;
16
+ private static TestLogger < WorkerProfileManager > _testLogger = new ( ) ;
17
+ private static TestEnvironment _testEnvironment = new ( ) ;
19
18
20
19
[ Fact ]
21
20
public void LoadWorkerDescriptionFromProfiles_ConditionsMet_ReturnsDescriptionWithChanges ( )
@@ -28,7 +27,7 @@ public void LoadWorkerDescriptionFromProfiles_ConditionsMet_ReturnsDescriptionWi
28
27
29
28
_testEnvironment . SetEnvironmentVariable ( "APPLICATIONINSIGHTS_ENABLE_AGENT" , "true" ) ;
30
29
31
- WorkerProfileManager profileManager = new ( _testLoggerFactory , _testEnvironment ) ;
30
+ WorkerProfileManager profileManager = new ( _testLogger , _testEnvironment ) ;
32
31
profileManager . SetWorkerDescriptionProfiles ( profiles , "java" ) ;
33
32
profileManager . LoadWorkerDescriptionFromProfiles ( defaultDescription , out var evaluatedDescription ) ;
34
33
@@ -44,7 +43,7 @@ public void LoadWorkerDescriptionFromProfiles_NoConditionsMet_ReturnsDefaultDesc
44
43
var profileDescription = RpcWorkerConfigTestUtilities . GetTestDefaultWorkerDescription ( "java" , argumentListB ) ;
45
44
var profiles = WorkerDescriptionProfileData ( "java" , profileDescription ) ;
46
45
47
- WorkerProfileManager profileManager = new ( _testLoggerFactory , _testEnvironment ) ;
46
+ WorkerProfileManager profileManager = new ( _testLogger , _testEnvironment ) ;
48
47
profileManager . SetWorkerDescriptionProfiles ( profiles , "java" ) ;
49
48
profileManager . LoadWorkerDescriptionFromProfiles ( defaultDescription , out var evaluatedDescription ) ;
50
49
@@ -60,7 +59,7 @@ public void TryCreateWorkerProfileCondition_ValidCondition_ReturnsTrue()
60
59
conditionJObject [ WorkerConstants . WorkerDescriptionProfileConditionExpression ] = "true" ;
61
60
var conditionDescriptor = conditionJObject . ToObject < WorkerProfileConditionDescriptor > ( ) ;
62
61
63
- WorkerProfileManager profileManager = new ( _testLoggerFactory , _testEnvironment ) ;
62
+ WorkerProfileManager profileManager = new ( _testLogger , _testEnvironment ) ;
64
63
var result = profileManager . TryCreateWorkerProfileCondition ( conditionDescriptor , out var condition ) ;
65
64
66
65
Assert . True ( result ) ;
@@ -75,7 +74,7 @@ public void TryCreateWorkerProfileCondition_InvalidCondition_ReturnsFalse()
75
74
conditionJObject [ WorkerConstants . WorkerDescriptionProfileConditionExpression ] = "true" ;
76
75
var conditionDescriptor = conditionJObject . ToObject < WorkerProfileConditionDescriptor > ( ) ;
77
76
78
- WorkerProfileManager profileManager = new ( _testLoggerFactory , _testEnvironment ) ;
77
+ WorkerProfileManager profileManager = new ( _testLogger , _testEnvironment ) ;
79
78
var result = profileManager . TryCreateWorkerProfileCondition ( conditionDescriptor , out var condition ) ;
80
79
81
80
Assert . False ( result ) ;
@@ -90,7 +89,7 @@ public void IsCorrectProfileLoaded_NoChange_ReturnsTrue()
90
89
91
90
_testEnvironment . SetEnvironmentVariable ( "APPLICATIONINSIGHTS_ENABLE_AGENT" , "true" ) ;
92
91
93
- WorkerProfileManager profileManager = new ( _testLoggerFactory , _testEnvironment ) ;
92
+ WorkerProfileManager profileManager = new ( _testLogger , _testEnvironment ) ;
94
93
profileManager . SetWorkerDescriptionProfiles ( profiles , "java" ) ;
95
94
profileManager . LoadWorkerDescriptionFromProfiles ( description , out var workerDescription ) ;
96
95
@@ -107,7 +106,7 @@ public void IsCorrectProfileLoaded_ConditionChange_ReturnsFalse()
107
106
108
107
_testEnvironment . SetEnvironmentVariable ( "APPLICATIONINSIGHTS_ENABLE_AGENT" , "true" ) ;
109
108
110
- WorkerProfileManager profileManager = new ( _testLoggerFactory , _testEnvironment ) ;
109
+ WorkerProfileManager profileManager = new ( _testLogger , _testEnvironment ) ;
111
110
profileManager . SetWorkerDescriptionProfiles ( profiles , "java" ) ;
112
111
profileManager . LoadWorkerDescriptionFromProfiles ( description , out var workerDescription ) ;
113
112
@@ -119,15 +118,15 @@ public void IsCorrectProfileLoaded_ConditionChange_ReturnsFalse()
119
118
120
119
public static List < WorkerDescriptionProfile > WorkerDescriptionProfileData ( string language , RpcWorkerDescription description )
121
120
{
122
- var logger = _testLoggerFactory . CreateLogger ( "WorkerProfileManagerTests ") ;
121
+ var conditionLogger = new TestLogger ( "ConditionLogger ") ;
123
122
var profilesList = new List < WorkerDescriptionProfile > ( ) ;
124
123
125
124
var conditionListA = new List < IWorkerProfileCondition > ( ) ;
126
- conditionListA . Add ( ProfilesTestUtilities . GetTestEnvironmentCondition ( logger , _testEnvironment , "APPLICATIONINSIGHTS_ENABLE_AGENT" , "true" ) ) ;
125
+ conditionListA . Add ( ProfilesTestUtilities . GetTestEnvironmentCondition ( conditionLogger , _testEnvironment , "APPLICATIONINSIGHTS_ENABLE_AGENT" , "true" ) ) ;
127
126
var profileA = new WorkerDescriptionProfile ( "profileA" , conditionListA , description ) ;
128
127
129
128
var conditionListB = new List < IWorkerProfileCondition > ( ) ;
130
- conditionListB . Add ( ProfilesTestUtilities . GetTestEnvironmentCondition ( logger , _testEnvironment , "APPLICATIONINSIGHTS_ENABLE_AGENT" , "false" ) ) ;
129
+ conditionListB . Add ( ProfilesTestUtilities . GetTestEnvironmentCondition ( conditionLogger , _testEnvironment , "APPLICATIONINSIGHTS_ENABLE_AGENT" , "false" ) ) ;
131
130
var profileB = new WorkerDescriptionProfile ( "profileB" , conditionListB , description ) ;
132
131
133
132
profilesList . Add ( profileA ) ;
0 commit comments