File tree Expand file tree Collapse file tree 2 files changed +7
-15
lines changed
Principle4.DryLogic.Tests Expand file tree Collapse file tree 2 files changed +7
-15
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ internal static readonly PropertyDefinition<Boolean> IsPresidentProperty
163
163
. IsRequired ( )
164
164
. IsConvertable ( )
165
165
. IsAdhearingTo ( oi => oi . GetValue ( IsPresidentProperty ) == false )
166
- . When ( oi => BirthDateProperty [ oi ] . AddYears ( 40 ) >= DateTime . Today )
166
+ . When ( oi => BirthDateProperty [ oi ] . AddYears ( 40 ) > DateTime . Today )
167
167
. WithMessage ( "{0} cannot be true if the employee is not yet 40" )
168
168
. IdentifiedBy ( "PRES40" ) ;
169
169
//New idea: I've started TypedPropertyRuleBuilder<T>
@@ -254,13 +254,14 @@ public void MakeValid()
254
254
HireDate = DateTime . Today ;
255
255
BirthDate = DateTime . Today . AddYears ( - 25 ) ;
256
256
LastName = "Levitt" ;
257
+ FirstName = "Brandon" ;
258
+ Score = 0 ;
257
259
}
258
260
public void MakeValidForPresident ( )
259
261
{
260
262
MakeValid ( ) ;
261
263
BirthDate = DateTime . Today . AddYears ( - 40 ) ;
262
264
IsPresident = true ;
263
-
264
265
}
265
266
266
267
Original file line number Diff line number Diff line change @@ -86,15 +86,6 @@ public void HireDateShouldBeAValidDate()
86
86
Assert . That ( violatedRule . AppliedRule is DBV . TypeConvertableRule , "Employee should not be valid since hire date cannot be converted to an datetime." ) ;
87
87
}
88
88
89
- [ Test ]
90
- public void NeedsAScore ( )
91
- {
92
- Employee . MakeValidForPresident ( ) ;
93
- var violatedRule = Employee . ScoreProperty . GetFirstRuleViolation ( Employee . OI ) ;
94
- Assert . That ( Employee . Score == null ) ;
95
-
96
- }
97
-
98
89
[ Test ]
99
90
100
91
public void PropertyChanged ( )
@@ -125,13 +116,13 @@ public void PropertyChanged()
125
116
[ Test ]
126
117
public void TestConditionalRule_IsPresident ( )
127
118
{
128
- Employee . MakeValid ( ) ;
129
- Assert . That ( Employee . OI . Validate ( ) , "Employee should be valid." ) ;
130
- Employee . BirthDate . AddDays ( - 1 ) ;
119
+ Employee . MakeValidForPresident ( ) ;
120
+ Assert . That ( Employee . OI . Validate ( ) , "Employee should be valid." + ( Employee . OI . GetRuleViolations ( ) . FirstOrDefault ( ) ? . ErrorMessage ) ) ;
121
+ Employee . BirthDate = Employee . BirthDate . AddDays ( 1 ) ;
131
122
132
123
var violatedRule = Employee . IsPresidentProperty . GetFirstRuleViolation ( Employee . OI ) ;
133
124
//TODO: Need rule ID setter so we can identify the proper rule.
134
- Assert . That ( violatedRule . AppliedRule . Id == "PRES40" , "Employee should have violated the PRES40 rule." ) ;
125
+ Assert . That ( violatedRule ? . AppliedRule . Id == "PRES40" , "Employee should have violated the PRES40 rule." ) ;
135
126
136
127
137
128
You can’t perform that action at this time.
0 commit comments