@@ -20,6 +20,12 @@ internal class TestableDefaultConfiguration : DefaultConfiguration
20
20
{
21
21
public TestableDefaultConfiguration ( IEnvironment environment , configuration localConfig , ServerConfiguration serverConfig , RunTimeConfiguration runTimeConfiguration , SecurityPoliciesConfiguration securityPoliciesConfiguration , IProcessStatic processStatic , IHttpRuntimeStatic httpRuntimeStatic , IConfigurationManagerStatic configurationManagerStatic , IDnsStatic dnsStatic )
22
22
: base ( environment , localConfig , serverConfig , runTimeConfiguration , securityPoliciesConfiguration , processStatic , httpRuntimeStatic , configurationManagerStatic , dnsStatic ) { }
23
+
24
+ public static void ResetStatics ( )
25
+ {
26
+ _agentEnabledAppSettingParsed = null ;
27
+ _appSettingAgentEnabled = false ;
28
+ }
23
29
}
24
30
25
31
[ TestFixture , Category ( "Configuration" ) ]
@@ -50,15 +56,40 @@ public void SetUp()
50
56
_dnsStatic = Mock . Create < IDnsStatic > ( ) ;
51
57
52
58
_defaultConfig = new TestableDefaultConfiguration ( _environment , _localConfig , _serverConfig , _runTimeConfig , _securityPoliciesConfiguration , _processStatic , _httpRuntimeStatic , _configurationManagerStatic , _dnsStatic ) ;
59
+
60
+ TestableDefaultConfiguration . ResetStatics ( ) ;
53
61
}
54
62
55
63
[ Test ]
56
64
public void AgentEnabledShouldPassThroughToLocalConfig ( )
57
65
{
58
66
Assert . IsTrue ( _defaultConfig . AgentEnabled ) ;
67
+
68
+ _localConfig . agentEnabled = false ;
69
+ Assert . IsFalse ( _defaultConfig . AgentEnabled ) ;
70
+
59
71
_localConfig . agentEnabled = true ;
60
72
Assert . IsTrue ( _defaultConfig . AgentEnabled ) ;
61
- _localConfig . agentEnabled = false ;
73
+ }
74
+
75
+ [ Test ]
76
+ public void AgentEnabledShouldUseCachedAppSetting ( )
77
+ {
78
+ Mock . Arrange ( ( ) => _configurationManagerStatic . GetAppSetting ( "NewRelic.AgentEnabled" ) ) . Returns ( "false" ) ;
79
+
80
+ Assert . IsFalse ( _defaultConfig . AgentEnabled ) ;
81
+ Assert . IsFalse ( _defaultConfig . AgentEnabled ) ;
82
+
83
+ Mock . Assert ( ( ) => _configurationManagerStatic . GetAppSetting ( "NewRelic.AgentEnabled" ) , Occurs . Once ( ) ) ;
84
+ }
85
+
86
+ [ Test ]
87
+ public void AgentEnabledShouldPreferAppSettingOverLocalConfig ( )
88
+ {
89
+ Mock . Arrange ( ( ) => _configurationManagerStatic . GetAppSetting ( "NewRelic.AgentEnabled" ) ) . Returns ( "false" ) ;
90
+
91
+ _localConfig . agentEnabled = true ;
92
+
62
93
Assert . IsFalse ( _defaultConfig . AgentEnabled ) ;
63
94
}
64
95
0 commit comments