1- using Lucca . Infra . Haproxy . AgentCheck . Config ;
1+ using Lucca . Infra . Haproxy . AgentCheck . Config ;
22using Lucca . Infra . Haproxy . AgentCheck . Metrics ;
33using Microsoft . Extensions . DependencyInjection ;
44using Xunit ;
5- using Xunit . Abstractions ;
65
76namespace Lucca . Infra . Haproxy . AgentCheck . Tests ;
87
@@ -25,7 +24,7 @@ public void Check_linear_weight_rule(WeightRuleData data)
2524 {
2625 Name = "CPU" ,
2726 Source = RuleSource . System ,
28- Weight = new ( )
27+ Weight = new WeightRule
2928 {
3029 SystemResponse = SystemResponse . Linear ,
3130 MinValue = data . MinValue ,
@@ -49,7 +48,7 @@ public void Check_firstOrder_weight_rule(WeightRuleData data)
4948 {
5049 Name = "CPU" ,
5150 Source = RuleSource . System ,
52- Weight = new ( )
51+ Weight = new WeightRule
5352 {
5453 SystemResponse = SystemResponse . FirstOrder ,
5554 MinValue = data . MinValue ,
@@ -68,20 +67,20 @@ public void Check_firstOrder_weight_rule(WeightRuleData data)
6867 public void Check_that_the_lowest_weight_is_used ( )
6968 {
7069 var serviceProvider = CreateServiceProvider (
71- new ( )
70+ new RuleConfig
7271 {
7372 Name = "CPU" ,
7473 Source = RuleSource . System ,
75- Weight = new ( )
74+ Weight = new WeightRule
7675 {
7776 SystemResponse = SystemResponse . Linear
7877 }
7978 } ,
80- new ( )
79+ new RuleConfig
8180 {
8281 Name = "IisRequests" ,
8382 Source = RuleSource . System ,
84- Weight = new ( )
83+ Weight = new WeightRule
8584 {
8685 SystemResponse = SystemResponse . Linear
8786 }
@@ -100,7 +99,7 @@ public void Check_that_given_metric_below_threshold_state_is_up()
10099 {
101100 Name = "CPU" ,
102101 Source = RuleSource . System ,
103- Failure = new ( )
102+ Failure = new FailureRule
104103 {
105104 EnterThreshold = 60 ,
106105 LeaveThreshold = 40
@@ -120,7 +119,7 @@ public void Check_that_given_metric_above_threshold_state_is_down()
120119 {
121120 Name = "CPU" ,
122121 Source = RuleSource . System ,
123- Failure = new ( )
122+ Failure = new FailureRule
124123 {
125124 EnterThreshold = 60 ,
126125 LeaveThreshold = 40
@@ -136,21 +135,21 @@ public void Check_that_given_metric_above_threshold_state_is_down()
136135 public void Check_that_given_one_metric_above_threshold_state_is_down ( )
137136 {
138137 var serviceProvider = CreateServiceProvider (
139- new ( )
138+ new RuleConfig
140139 {
141140 Name = "CPU" ,
142141 Source = RuleSource . System ,
143- Failure = new ( )
142+ Failure = new FailureRule
144143 {
145144 EnterThreshold = 60 ,
146145 LeaveThreshold = 40
147146 }
148147 } ,
149- new ( )
148+ new RuleConfig
150149 {
151150 Name = "IisRequests" ,
152151 Source = RuleSource . System ,
153- Failure = new ( )
152+ Failure = new FailureRule
154153 {
155154 EnterThreshold = 10 ,
156155 LeaveThreshold = 10
@@ -171,7 +170,7 @@ public void Check_that_given_broken_circuit_breaker_with_metric_between_threshol
171170 {
172171 Name = "CPU" ,
173172 Source = RuleSource . System ,
174- Failure = new ( )
173+ Failure = new FailureRule
175174 {
176175 EnterThreshold = 60 ,
177176 LeaveThreshold = 40
@@ -192,7 +191,7 @@ public void Check_that_given_broken_circuit_breaker_with_metric_below_threshold_
192191 {
193192 Name = "CPU" ,
194193 Source = RuleSource . System ,
195- Failure = new ( )
194+ Failure = new FailureRule
196195 {
197196 EnterThreshold = 60 ,
198197 LeaveThreshold = 40
@@ -213,7 +212,7 @@ public void Check_that_given_broken_circuit_breaker_with_metric_below_threshold_
213212 {
214213 Name = "CPU" ,
215214 Source = RuleSource . System ,
216- Failure = new ( )
215+ Failure = new FailureRule
217216 {
218217 EnterThreshold = 60 ,
219218 LeaveThreshold = 40 ,
@@ -235,7 +234,7 @@ public void Check_that_given_broken_circuit_breaker_with_metric_below_threshold_
235234 {
236235 Name = "CPU" ,
237236 Source = RuleSource . System ,
238- Failure = new ( )
237+ Failure = new FailureRule
239238 {
240239 EnterThreshold = 60 ,
241240 LeaveThreshold = 40 ,
@@ -259,7 +258,7 @@ public void Check_that_given_fixed_circuit_breaker_with_metric_not_below_thresho
259258 {
260259 Name = "CPU" ,
261260 Source = RuleSource . System ,
262- Failure = new ( )
261+ Failure = new FailureRule
263262 {
264263 EnterThreshold = 60 ,
265264 LeaveThreshold = 40 ,
@@ -277,42 +276,41 @@ public void Check_that_given_fixed_circuit_breaker_with_metric_not_below_thresho
277276
278277 public static TheoryData < WeightRuleData > GetLinearResponseTestData ( )
279278 {
280- return new TheoryData < WeightRuleData >
281- {
282- new ( 0 , 100 , 0 , 100 , 0 , 100 ) ,
283- new ( 50 , 50 , 0 , 100 , 0 , 100 ) ,
284- new ( 100 , 0 , 0 , 100 , 0 , 100 ) ,
279+ return new TheoryData < WeightRuleData > (
280+ new WeightRuleData ( 0 , 100 , 0 , 100 , 0 , 100 ) ,
281+ new WeightRuleData ( 50 , 50 , 0 , 100 , 0 , 100 ) ,
282+ new WeightRuleData ( 100 , 0 , 0 , 100 , 0 , 100 ) ,
285283
286- new ( 0 , 80 , 0 , 100 , 10 , 80 ) ,
287- new ( 50 , 45 , 0 , 100 , 10 , 80 ) ,
288- new ( 100 , 10 , 0 , 100 , 10 , 80 ) ,
284+ new WeightRuleData ( 0 , 80 , 0 , 100 , 10 , 80 ) ,
285+ new WeightRuleData ( 50 , 45 , 0 , 100 , 10 , 80 ) ,
286+ new WeightRuleData ( 100 , 10 , 0 , 100 , 10 , 80 ) ,
289287
290- new ( 0 , 100 , 10 , 80 , 0 , 100 ) ,
291- new ( 10 , 100 , 10 , 80 , 0 , 100 ) ,
292- new ( 50 , 42.85 , 10 , 80 , 0 , 100 ) ,
293- new ( 80 , 0 , 10 , 80 , 0 , 100 ) ,
294- new ( 100 , 0 , 10 , 80 , 0 , 100 )
295- } ;
288+ new WeightRuleData ( 0 , 100 , 10 , 80 , 0 , 100 ) ,
289+ new WeightRuleData ( 10 , 100 , 10 , 80 , 0 , 100 ) ,
290+ new WeightRuleData ( 50 , 42.85 , 10 , 80 , 0 , 100 ) ,
291+ new WeightRuleData ( 80 , 0 , 10 , 80 , 0 , 100 ) ,
292+ new WeightRuleData ( 100 , 0 , 10 , 80 , 0 , 100 )
293+ ) ;
296294 }
297295
298296 public static TheoryData < WeightRuleData > GetFirstOrderResponseTestData ( )
299297 {
300- return new TheoryData < WeightRuleData >
301- {
302- new ( 0 , 100 , 0 , 100 , 0 , 100 ) ,
303- new ( 50 , 9.05 , 0 , 100 , 0 , 100 ) ,
304- new ( 100 , 0 , 0 , 100 , 0 , 100 ) ,
298+ return new TheoryData < WeightRuleData > (
299+
300+ new WeightRuleData ( 0 , 100 , 0 , 100 , 0 , 100 ) ,
301+ new WeightRuleData ( 50 , 9.05 , 0 , 100 , 0 , 100 ) ,
302+ new WeightRuleData ( 100 , 0 , 0 , 100 , 0 , 100 ) ,
305303
306- new ( 0 , 80 , 0 , 100 , 10 , 80 ) ,
307- new ( 50 , 17.42 , 0 , 100 , 10 , 80 ) ,
308- new ( 100 , 10 , 0 , 100 , 10 , 80 ) ,
304+ new WeightRuleData ( 0 , 80 , 0 , 100 , 10 , 80 ) ,
305+ new WeightRuleData ( 50 , 17.42 , 0 , 100 , 10 , 80 ) ,
306+ new WeightRuleData ( 100 , 10 , 0 , 100 , 10 , 80 ) ,
309307
310- new ( 0 , 100 , 10 , 80 , 0 , 100 ) ,
311- new ( 10 , 100 , 10 , 80 , 0 , 100 ) ,
312- new ( 45 , 9.05 , 10 , 80 , 0 , 100 ) ,
313- new ( 80 , 0 , 10 , 80 , 0 , 100 ) ,
314- new ( 100 , 0 , 10 , 80 , 0 , 100 )
315- } ;
308+ new WeightRuleData ( 0 , 100 , 10 , 80 , 0 , 100 ) ,
309+ new WeightRuleData ( 10 , 100 , 10 , 80 , 0 , 100 ) ,
310+ new WeightRuleData ( 45 , 9.05 , 10 , 80 , 0 , 100 ) ,
311+ new WeightRuleData ( 80 , 0 , 10 , 80 , 0 , 100 ) ,
312+ new WeightRuleData ( 100 , 0 , 10 , 80 , 0 , 100 )
313+ ) ;
316314 }
317315
318316 private IServiceProvider CreateServiceProvider ( params RuleConfig [ ] rules )
0 commit comments