3
3
4
4
using System . Collections . Generic ;
5
5
using System . ComponentModel . DataAnnotations ;
6
- using Microsoft . Azure . WebJobs . Script . Tests ;
7
- using Microsoft . Azure . WebJobs . Script . Tests . Workers . Profiles ;
8
6
using Microsoft . Azure . WebJobs . Script . Tests . Workers . Rpc ;
7
+ using Microsoft . Azure . WebJobs . Script . Workers ;
9
8
using Microsoft . Azure . WebJobs . Script . Workers . Rpc ;
10
9
using Xunit ;
11
10
12
- namespace Microsoft . Azure . WebJobs . Script . Workers . Profiles
11
+ namespace Microsoft . Azure . WebJobs . Script . Tests . Workers . Profiles
13
12
{
14
13
public class WorkerDescriptionProfileTests
15
14
{
@@ -21,9 +20,9 @@ public class WorkerDescriptionProfileTests
21
20
22
21
[ Theory ]
23
22
[ MemberData ( nameof ( WorkerDescriptionProfileExceptionData ) ) ]
24
- public void WorkerDescriptionProfile_ThrowsValidationException ( string name , List < IWorkerProfileCondition > coditions , RpcWorkerDescription workerDescription )
23
+ public void WorkerDescriptionProfile_ThrowsValidationException ( string name , List < IWorkerProfileCondition > conditions , RpcWorkerDescription workerDescription )
25
24
{
26
- Assert . Throws < ValidationException > ( ( ) => new WorkerDescriptionProfile ( name , coditions , workerDescription ) ) ;
25
+ Assert . Throws < ValidationException > ( ( ) => new WorkerDescriptionProfile ( name , conditions , workerDescription ) ) ;
27
26
}
28
27
29
28
public static IEnumerable < object [ ] > WorkerDescriptionProfileExceptionData ( )
@@ -43,16 +42,19 @@ public static IEnumerable<object[]> WorkerDescriptionProfileExceptionData()
43
42
44
43
[ Theory ]
45
44
[ MemberData ( nameof ( WorkerDescriptionProfileData ) ) ]
46
- public void WorkerDescriptionProfile_ApplyProfile ( string name , List < IWorkerProfileCondition > coditions , RpcWorkerDescription workerDescription )
45
+ public void WorkerDescriptionProfile_ApplyProfile ( string name , List < IWorkerProfileCondition > conditions , RpcWorkerDescription workerDescription )
47
46
{
48
47
_testEnvironment . SetEnvironmentVariable ( "APPLICATIONINSIGHTS_ENABLE_AGENT" , "true" ) ;
49
48
var defaultDescription = RpcWorkerConfigTestUtilities . GetTestDefaultWorkerDescription ( "java" , new string [ ] { "-DefaultArgs" } ) ;
50
49
51
- var workerDescriptionProfile = new WorkerDescriptionProfile ( name , coditions , workerDescription ) ;
50
+ var workerDescriptionProfile = new WorkerDescriptionProfile ( name , conditions , workerDescription ) ;
52
51
defaultDescription = workerDescriptionProfile . ApplyProfile ( defaultDescription ) ;
53
52
54
53
Assert . Equal ( defaultDescription . Arguments [ 0 ] , argumentList [ 0 ] ) ;
55
54
Assert . NotEqual ( defaultDescription . Arguments [ 0 ] , "-DefaultArgs" ) ;
55
+
56
+ // Reset environment
57
+ _testEnvironment = new TestEnvironment ( ) ;
56
58
}
57
59
58
60
public static IEnumerable < object [ ] > WorkerDescriptionProfileData ( )
@@ -69,16 +71,19 @@ public static IEnumerable<object[]> WorkerDescriptionProfileData()
69
71
70
72
[ Theory ]
71
73
[ MemberData ( nameof ( WorkerDescriptionProfileInvalidData ) ) ]
72
- public void WorkerDescriptionProfile_DoNotApplyProfile ( string name , List < IWorkerProfileCondition > coditions , RpcWorkerDescription workerDescription )
74
+ public void WorkerDescriptionProfile_DoNotApplyProfile ( string name , List < IWorkerProfileCondition > conditions , RpcWorkerDescription workerDescription )
73
75
{
74
76
_testEnvironment . SetEnvironmentVariable ( "APPLICATIONINSIGHTS_ENABLE_AGENT" , "false" ) ;
75
77
var defaultDescription = RpcWorkerConfigTestUtilities . GetTestDefaultWorkerDescription ( "java" , new string [ ] { "-DefaultArgs" } ) ;
76
78
77
- var workerDescriptionProfile = new WorkerDescriptionProfile ( name , coditions , workerDescription ) ;
79
+ var workerDescriptionProfile = new WorkerDescriptionProfile ( name , conditions , workerDescription ) ;
78
80
defaultDescription = workerDescriptionProfile . ApplyProfile ( defaultDescription ) ;
79
81
80
82
Assert . NotNull ( defaultDescription . Arguments [ 0 ] ) ;
81
83
Assert . Equal ( defaultDescription . Arguments [ 0 ] , "-DefaultArgs" ) ;
84
+
85
+ // Reset environment
86
+ _testEnvironment = new TestEnvironment ( ) ;
82
87
}
83
88
84
89
public static IEnumerable < object [ ] > WorkerDescriptionProfileInvalidData ( )
@@ -115,6 +120,9 @@ public void WorkerDescriptionProfile_EvaluateConditions()
115
120
workerDescriptionProfile = new WorkerDescriptionProfile ( "profileName" , conditions , description ) ;
116
121
117
122
Assert . False ( workerDescriptionProfile . EvaluateConditions ( ) ) ;
123
+
124
+ // Reset environment
125
+ _testEnvironment = new TestEnvironment ( ) ;
118
126
}
119
127
}
120
128
}
0 commit comments