1818using NUnit . Framework ;
1919using OptimizelySDK . AudienceConditions ;
2020using OptimizelySDK . Entity ;
21+ using OptimizelySDK . Logger ;
2122
2223namespace OptimizelySDK . Tests . AudienceConditionsTests
2324{
@@ -32,19 +33,26 @@ public class ConditionsTest
3233 private ICondition FalseCondition ;
3334 private ICondition NullCondition ;
3435
36+ private ILogger Logger ;
37+ private Mock < ILogger > MockLogger ;
38+
3539 [ TestFixtureSetUp ]
3640 public void Initialize ( )
3741 {
3842 TrueConditionMock = new Mock < ICondition > ( ) ;
39- TrueConditionMock . Setup ( condition => condition . Evaluate ( It . IsAny < ProjectConfig > ( ) , It . IsAny < UserAttributes > ( ) ) ) . Returns ( true ) ;
43+ TrueConditionMock . Setup ( condition => condition . Evaluate ( It . IsAny < ProjectConfig > ( ) , It . IsAny < UserAttributes > ( ) , It . IsAny < ILogger > ( ) ) ) . Returns ( true ) ;
4044 FalseConditionMock = new Mock < ICondition > ( ) ;
41- FalseConditionMock . Setup ( condition => condition . Evaluate ( It . IsAny < ProjectConfig > ( ) , It . IsAny < UserAttributes > ( ) ) ) . Returns ( false ) ;
45+ FalseConditionMock . Setup ( condition => condition . Evaluate ( It . IsAny < ProjectConfig > ( ) , It . IsAny < UserAttributes > ( ) , It . IsAny < ILogger > ( ) ) ) . Returns ( false ) ;
4246 NullConditionMock = new Mock < ICondition > ( ) ;
43- NullConditionMock . Setup ( condition => condition . Evaluate ( It . IsAny < ProjectConfig > ( ) , It . IsAny < UserAttributes > ( ) ) ) . Returns ( ( bool ? ) null ) ;
47+ NullConditionMock . Setup ( condition => condition . Evaluate ( It . IsAny < ProjectConfig > ( ) , It . IsAny < UserAttributes > ( ) , It . IsAny < ILogger > ( ) ) ) . Returns ( ( bool ? ) null ) ;
4448
4549 TrueCondition = TrueConditionMock . Object ;
4650 FalseCondition = FalseConditionMock . Object ;
4751 NullCondition = NullConditionMock . Object ;
52+
53+ MockLogger = new Mock < ILogger > ( ) ;
54+ MockLogger . Setup ( l => l . Log ( It . IsAny < LogLevel > ( ) , It . IsAny < string > ( ) ) ) ;
55+ Logger = MockLogger . Object ;
4856 }
4957
5058 #region AND Condition Tests
@@ -55,7 +63,7 @@ public void TestAndEvaluatorReturnsTrueWhenAllOperandsEvaluateToTrue()
5563 ICondition [ ] conditions = new ICondition [ ] { TrueCondition , TrueCondition } ;
5664 var andCondition = new AndCondition { Conditions = conditions } ;
5765
58- Assert . That ( andCondition . Evaluate ( null , null ) , Is . True ) ;
66+ Assert . That ( andCondition . Evaluate ( null , null , Logger ) , Is . True ) ;
5967 }
6068
6169 [ Test ]
@@ -64,10 +72,10 @@ public void TestAndEvaluatorReturnsFalseWhenAnyOperandEvaluatesToFalse()
6472 ICondition [ ] conditions = new ICondition [ ] { FalseCondition , TrueCondition } ;
6573 var andCondition = new AndCondition { Conditions = conditions } ;
6674
67- Assert . That ( andCondition . Evaluate ( null , null ) , Is . False ) ;
75+ Assert . That ( andCondition . Evaluate ( null , null , Logger ) , Is . False ) ;
6876
6977 // Should not be called due to short circuiting.
70- TrueConditionMock . Verify ( condition => condition . Evaluate ( It . IsAny < ProjectConfig > ( ) , It . IsAny < UserAttributes > ( ) ) , Times . Never ) ;
78+ TrueConditionMock . Verify ( condition => condition . Evaluate ( It . IsAny < ProjectConfig > ( ) , It . IsAny < UserAttributes > ( ) , Logger ) , Times . Never ) ;
7179 }
7280
7381 [ Test ]
@@ -76,7 +84,7 @@ public void TestAndEvaluatorReturnsNullWhenAllOperandsEvaluateToNull()
7684 ICondition [ ] conditions = new ICondition [ ] { NullCondition , NullCondition } ;
7785 var andCondition = new AndCondition { Conditions = conditions } ;
7886
79- Assert . That ( andCondition . Evaluate ( null , null ) , Is . Null ) ;
87+ Assert . That ( andCondition . Evaluate ( null , null , Logger ) , Is . Null ) ;
8088 }
8189
8290 [ Test ]
@@ -85,7 +93,7 @@ public void TestAndEvaluatorReturnsNullWhenOperandsEvaluateToTrueAndNull()
8593 ICondition [ ] conditions = new ICondition [ ] { TrueCondition , NullCondition , TrueCondition } ;
8694 var andCondition = new AndCondition { Conditions = conditions } ;
8795
88- Assert . That ( andCondition . Evaluate ( null , null ) , Is . Null ) ;
96+ Assert . That ( andCondition . Evaluate ( null , null , Logger ) , Is . Null ) ;
8997 }
9098
9199 [ Test ]
@@ -94,7 +102,7 @@ public void TestAndEvaluatorReturnsFalseWhenOperandsEvaluateToFalseAndNull()
94102 ICondition [ ] conditions = new ICondition [ ] { NullCondition , FalseCondition , NullCondition } ;
95103 var andCondition = new AndCondition { Conditions = conditions } ;
96104
97- Assert . That ( andCondition . Evaluate ( null , null ) , Is . False ) ;
105+ Assert . That ( andCondition . Evaluate ( null , null , Logger ) , Is . False ) ;
98106 }
99107
100108 [ Test ]
@@ -103,7 +111,7 @@ public void TestAndEvaluatorReturnsFalseWhenOperandsEvaluateToTrueFalseAndNull()
103111 ICondition [ ] conditions = new ICondition [ ] { TrueCondition , FalseCondition , NullCondition } ;
104112 var andCondition = new AndCondition { Conditions = conditions } ;
105113
106- Assert . That ( andCondition . Evaluate ( null , null ) , Is . False ) ;
114+ Assert . That ( andCondition . Evaluate ( null , null , Logger ) , Is . False ) ;
107115 }
108116
109117 #endregion // AND Condition Tests
@@ -116,7 +124,7 @@ public void TestOrEvaluatorReturnsTrueWhenAnyOperandEvaluatesToTrue()
116124 ICondition [ ] conditions = new ICondition [ ] { TrueCondition , FalseCondition , NullCondition } ;
117125 var orCondition = new OrCondition { Conditions = conditions } ;
118126
119- Assert . That ( orCondition . Evaluate ( null , null ) , Is . True ) ;
127+ Assert . That ( orCondition . Evaluate ( null , null , Logger ) , Is . True ) ;
120128 }
121129
122130 [ Test ]
@@ -125,7 +133,7 @@ public void TestOrEvaluatorReturnsFalseWhenAllOperandsEvaluatesToFalse()
125133 ICondition [ ] conditions = new ICondition [ ] { FalseCondition , FalseCondition } ;
126134 var orCondition = new OrCondition { Conditions = conditions } ;
127135
128- Assert . That ( orCondition . Evaluate ( null , null ) , Is . False ) ;
136+ Assert . That ( orCondition . Evaluate ( null , null , Logger ) , Is . False ) ;
129137 }
130138
131139 [ Test ]
@@ -134,7 +142,7 @@ public void TestOrEvaluatorReturnsNullWhenOperandsEvaluateToFalseAndNull()
134142 ICondition [ ] conditions = new ICondition [ ] { FalseCondition , NullCondition , FalseCondition } ;
135143 var orCondition = new OrCondition { Conditions = conditions } ;
136144
137- Assert . That ( orCondition . Evaluate ( null , null ) , Is . Null ) ;
145+ Assert . That ( orCondition . Evaluate ( null , null , Logger ) , Is . Null ) ;
138146 }
139147
140148 [ Test ]
@@ -143,7 +151,7 @@ public void TestOrEvaluatorReturnsTrueWhenOperandsEvaluateToTrueAndNull()
143151 ICondition [ ] conditions = new ICondition [ ] { TrueCondition , NullCondition , TrueCondition } ;
144152 var orCondition = new OrCondition { Conditions = conditions } ;
145153
146- Assert . That ( orCondition . Evaluate ( null , null ) , Is . True ) ;
154+ Assert . That ( orCondition . Evaluate ( null , null , Logger ) , Is . True ) ;
147155 }
148156
149157 [ Test ]
@@ -152,7 +160,7 @@ public void TestOrEvaluatorReturnsTrueWhenOperandsEvaluateToFalseTrueAndNull()
152160 ICondition [ ] conditions = new ICondition [ ] { FalseCondition , NullCondition , TrueCondition } ;
153161 var orCondition = new OrCondition { Conditions = conditions } ;
154162
155- Assert . That ( orCondition . Evaluate ( null , null ) , Is . True ) ;
163+ Assert . That ( orCondition . Evaluate ( null , null , Logger ) , Is . True ) ;
156164 }
157165
158166 #endregion // OR Condition Tests
@@ -163,28 +171,28 @@ public void TestOrEvaluatorReturnsTrueWhenOperandsEvaluateToFalseTrueAndNull()
163171 public void TestNotEvaluatorReturnsNullWhenOperandEvaluateToNull ( )
164172 {
165173 var notCondition = new NotCondition { Condition = NullCondition } ;
166- Assert . That ( notCondition . Evaluate ( null , null ) , Is . Null ) ;
174+ Assert . That ( notCondition . Evaluate ( null , null , Logger ) , Is . Null ) ;
167175 }
168176
169177 [ Test ]
170178 public void TestNotEvaluatorReturnsTrueWhenOperandEvaluateToFalse ( )
171179 {
172180 var notCondition = new NotCondition { Condition = FalseCondition } ;
173- Assert . That ( notCondition . Evaluate ( null , null ) , Is . True ) ;
181+ Assert . That ( notCondition . Evaluate ( null , null , Logger ) , Is . True ) ;
174182 }
175183
176184 [ Test ]
177185 public void TestNotEvaluatorReturnsFalseWhenOperandEvaluateToTrue ( )
178186 {
179187 var notCondition = new NotCondition { Condition = TrueCondition } ;
180- Assert . That ( notCondition . Evaluate ( null , null ) , Is . False ) ;
188+ Assert . That ( notCondition . Evaluate ( null , null , Logger ) , Is . False ) ;
181189 }
182190
183191 [ Test ]
184192 public void TestNotEvaluatorReturnsNullWhenConditionIsNull ( )
185193 {
186194 var notCondition = new NotCondition { Condition = null } ;
187- Assert . That ( notCondition . Evaluate ( null , null ) , Is . Null ) ;
195+ Assert . That ( notCondition . Evaluate ( null , null , Logger ) , Is . Null ) ;
188196 }
189197
190198 #endregion // NOT Condition Tests
0 commit comments