@@ -42,6 +42,9 @@ public void AndThen() { }
42
42
43
43
[ AndGiven ]
44
44
public void SomeOtherPartOfTheGiven ( ) { }
45
+
46
+ [ But ]
47
+ public void IDontWantThisToBeTrue ( ) { }
45
48
}
46
49
47
50
[ SetUp ]
@@ -59,166 +62,69 @@ private static string GetStepTextFromMethodName(Action methodInfoAction)
59
62
[ Test ]
60
63
public void DecoratedMethodsAreReturned ( )
61
64
{
62
- Assert . That ( _steps . Count , Is . EqualTo ( 7 ) ) ;
63
- }
64
-
65
- Step GivenStep
66
- {
67
- get
68
- {
69
- return _steps . Single ( s => s . Title == "Given" ) ;
70
- }
71
- }
72
-
73
- [ Test ]
74
- public void GivenStep_IsFoundAsSetupState ( )
75
- {
76
- Assert . That ( GivenStep . ExecutionOrder , Is . EqualTo ( ExecutionOrder . SetupState ) ) ;
77
- }
78
-
79
- [ Test ]
80
- public void GivenStep_DoesNotAssert ( )
81
- {
82
- Assert . IsFalse ( GivenStep . Asserts ) ;
83
- }
84
-
85
- [ Test ]
86
- public void GivenStep_TextIsFetchedFromMethodName ( )
87
- {
88
- Assert . That ( GivenStep . Title . Trim ( ) , Is . EqualTo ( GetStepTextFromMethodName ( _typeWithAttribute . Given ) ) ) ;
89
- }
90
-
91
- Step AndGivenStep
92
- {
93
- get
94
- {
95
- return _steps . Single ( s => s . Title . Trim ( ) == "Some other part of the given" ) ;
96
- }
97
- }
98
-
99
- [ Test ]
100
- public void AndGivenIsFoundAsConsequtiveSetupState ( )
101
- {
102
- Assert . That ( AndGivenStep . ExecutionOrder , Is . EqualTo ( ExecutionOrder . ConsecutiveSetupState ) ) ;
103
- }
104
-
105
- [ Test ]
106
- public void AndGivenStepDoesNotAssert ( )
107
- {
108
- Assert . IsFalse ( AndGivenStep . Asserts ) ;
109
- }
110
-
111
- [ Test ]
112
- public void AndGivenStepTextIsFetchedFromMethodName ( )
113
- {
114
- Assert . That ( AndGivenStep . Title . Trim ( ) , Is . EqualTo ( GetStepTextFromMethodName ( _typeWithAttribute . SomeOtherPartOfTheGiven ) ) ) ;
115
- }
116
-
117
- Step WhenStep
118
- {
119
- get
120
- {
121
- return _steps . Single ( s => s . Title == TypeWithAttribute . MethodTextForWhenSomethingHappens ) ;
122
- }
123
- }
124
-
125
- [ Test ]
126
- public void WhenStep_IsFoundAsTransitionStep ( )
127
- {
128
- Assert . That ( WhenStep . ExecutionOrder , Is . EqualTo ( ExecutionOrder . Transition ) ) ;
129
- }
130
-
131
- [ Test ]
132
- public void WhenStep_StepTextIsFetchedFromExecutableAttribute ( )
133
- {
134
- Assert . That ( WhenStep . Title , Is . EqualTo ( TypeWithAttribute . MethodTextForWhenSomethingHappens ) ) ;
65
+ Assert . That ( _steps . Count , Is . EqualTo ( 8 ) ) ;
135
66
}
136
67
137
68
[ Test ]
138
- public void WhenStep_StepDoesNotAssert ( )
139
- {
140
- Assert . IsFalse ( WhenStep . Asserts ) ;
141
- }
142
-
143
- Step TheOtherPartOfWhenStep
69
+ public void Given ( )
144
70
{
145
- get
146
- {
147
- return _steps . Single ( s => s . Title . Trim ( ) == "The other part of when" ) ;
148
- }
71
+ var givenStep = _steps . Single ( s => s . Title == "Given" ) ;
72
+ Assert . That ( givenStep . ExecutionOrder , Is . EqualTo ( ExecutionOrder . SetupState ) ) ;
73
+ Assert . IsFalse ( givenStep . Asserts ) ;
74
+ Assert . That ( givenStep . Title . Trim ( ) , Is . EqualTo ( GetStepTextFromMethodName ( _typeWithAttribute . Given ) ) ) ;
149
75
}
150
76
151
77
[ Test ]
152
- public void TheOtherPartOfWhenStep_IsFoundAsConsecutiveTransition ( )
78
+ public void AndGiven ( )
153
79
{
154
- Assert . That ( TheOtherPartOfWhenStep . ExecutionOrder , Is . EqualTo ( ExecutionOrder . ConsecutiveTransition ) ) ;
80
+ var step = _steps . Single ( s => s . Title . Trim ( ) == "Some other part of the given" ) ;
81
+ Assert . That ( step . ExecutionOrder , Is . EqualTo ( ExecutionOrder . ConsecutiveSetupState ) ) ;
82
+ Assert . IsFalse ( step . Asserts ) ;
83
+ Assert . That ( step . Title . Trim ( ) , Is . EqualTo ( GetStepTextFromMethodName ( _typeWithAttribute . SomeOtherPartOfTheGiven ) ) ) ;
155
84
}
156
85
157
86
[ Test ]
158
- public void TheOtherPartOfWhenStep_StepTextIsFetchedFromMethodName ( )
87
+ public void When ( )
159
88
{
160
- Assert . That ( TheOtherPartOfWhenStep . Title . Trim ( ) , Is . EqualTo ( GetStepTextFromMethodName ( _typeWithAttribute . TheOtherPartOfWhen ) ) ) ;
89
+ var step = _steps . Single ( s => s . Title == TypeWithAttribute . MethodTextForWhenSomethingHappens ) ;
90
+ Assert . That ( step . ExecutionOrder , Is . EqualTo ( ExecutionOrder . Transition ) ) ;
91
+ Assert . That ( step . Title , Is . EqualTo ( TypeWithAttribute . MethodTextForWhenSomethingHappens ) ) ;
92
+ Assert . IsFalse ( step . Asserts ) ;
161
93
}
162
94
163
95
[ Test ]
164
- public void TheOtherPartOfWhenStep_StepDoesNotAssert ( )
96
+ public void TheOtherPartOfWhen ( )
165
97
{
166
- Assert . IsFalse ( TheOtherPartOfWhenStep . Asserts ) ;
98
+ var step = _steps . Single ( s => s . Title . Trim ( ) == "The other part of when" ) ;
99
+ Assert . That ( step . ExecutionOrder , Is . EqualTo ( ExecutionOrder . ConsecutiveTransition ) ) ;
100
+ Assert . That ( step . Title . Trim ( ) , Is . EqualTo ( GetStepTextFromMethodName ( _typeWithAttribute . TheOtherPartOfWhen ) ) ) ;
101
+ Assert . IsFalse ( step . Asserts ) ;
167
102
}
168
103
169
104
[ Test ]
170
- public void ThenStepsAreReturnedAsAssertingSteps ( )
105
+ public void ThenStepsWithArgs ( )
171
106
{
172
- var steps = ThenSteps . ToList ( ) ;
107
+ var steps = _steps . Where ( s => s . Title == "Then 1, 2" || s . Title == "Then 3, 4" ) . ToList ( ) ;
173
108
Assert . IsTrue ( steps . All ( s => s . ExecutionOrder == ExecutionOrder . Assertion ) ) ;
174
- }
175
-
176
- IEnumerable < Step > ThenSteps
177
- {
178
- get
179
- {
180
- return _steps . Where ( s => s . Title == "Then 1, 2" || s . Title == "Then 3, 4" ) ;
181
- }
182
- }
183
-
184
- [ Test ]
185
- public void ThenSteps_DoAssert ( )
186
- {
187
- var steps = ThenSteps . ToList ( ) ;
188
- Assert . True ( steps . All ( s => s . Asserts ) ) ;
189
- }
190
-
191
- [ Test ]
192
- public void ThenSteps_StepTextIsFetchedFromMethodNamePostfixedWithArguments ( )
193
- {
194
- var steps = ThenSteps . ToList ( ) ;
109
+ Assert . IsTrue ( steps . All ( s => s . Asserts ) ) ;
195
110
Assert . IsTrue ( steps . All ( s => s . Title . EndsWith ( " 1, 2" ) || s . Title . EndsWith ( " 3, 4" ) ) ) ;
196
111
}
197
112
198
- Step AndThenStep
199
- {
200
- get
201
- {
202
- return _steps . Single ( s => s . Title . Trim ( ) == TypeWithAttribute . MethodTextForAndThen ) ;
203
- }
204
- }
205
-
206
- [ Test ]
207
- public void AndThenStep_IsFoundAndConsecutiveAssertingStep ( )
208
- {
209
- Assert . That ( AndThenStep . ExecutionOrder , Is . EqualTo ( ExecutionOrder . ConsecutiveAssertion ) ) ;
210
- }
211
-
212
113
[ Test ]
213
- public void AndThenStep_Asserts ( )
114
+ public void AndThen ( )
214
115
{
215
- Assert . IsTrue ( AndThenStep . Asserts ) ;
116
+ var step = _steps . Single ( s => s . Title . Trim ( ) == TypeWithAttribute . MethodTextForAndThen ) ;
117
+ Assert . That ( step . ExecutionOrder , Is . EqualTo ( ExecutionOrder . ConsecutiveAssertion ) ) ;
118
+ Assert . IsTrue ( step . Asserts ) ;
119
+ Assert . That ( step . Title . Trim ( ) , Is . EqualTo ( TypeWithAttribute . MethodTextForAndThen ) ) ;
216
120
}
217
121
218
122
[ Test ]
219
- public void AndThenStep_StepTextIsFetchedFromExecutableAttribute ( )
123
+ public void But ( )
220
124
{
221
- Assert . That ( AndThenStep . Title . Trim ( ) , Is . EqualTo ( TypeWithAttribute . MethodTextForAndThen ) ) ;
125
+ var step = _steps . Single ( s => s . Title == "I dont want this to be true" ) ;
126
+ Assert . That ( step . ExecutionOrder , Is . EqualTo ( ExecutionOrder . ConsecutiveAssertion ) ) ;
127
+ Assert . IsTrue ( step . Asserts ) ;
222
128
}
223
129
}
224
130
}
0 commit comments