@@ -105,17 +105,11 @@ public void Run_All_Scenarios ()
105
105
106
106
Application . Shutdown ( ) ;
107
107
#if DEBUG_IDISPOSABLE
108
- foreach ( var inst in Responder . Instances ) {
109
- Assert . True ( inst . WasDisposed ) ;
110
- }
111
- Responder . Instances . Clear ( ) ;
108
+ Assert . Empty ( Responder . Instances ) ;
112
109
#endif
113
110
}
114
111
#if DEBUG_IDISPOSABLE
115
- foreach ( var inst in Responder . Instances ) {
116
- Assert . True ( inst . WasDisposed ) ;
117
- }
118
- Responder . Instances . Clear ( ) ;
112
+ Assert . Empty ( Responder . Instances ) ;
119
113
#endif
120
114
}
121
115
@@ -132,11 +126,24 @@ public void Run_Generic ()
132
126
// BUGBUG: (#2474) For some reason ReadKey is not returning the QuitKey for some Scenarios
133
127
// by adding this Space it seems to work.
134
128
135
- FakeConsole . PushMockKeyPress ( Key . Space ) ;
136
129
FakeConsole . PushMockKeyPress ( Application . QuitKey ) ;
137
130
131
+ var ms = 100 ;
132
+ var abortCount = 0 ;
133
+ Func < MainLoop , bool > abortCallback = ( MainLoop loop ) => {
134
+ abortCount ++ ;
135
+ output . WriteLine ( $ "'Generic' abortCount { abortCount } ") ;
136
+ Application . RequestStop ( ) ;
137
+ return false ;
138
+ } ;
139
+
138
140
int iterations = 0 ;
141
+ object token = null ;
139
142
Application . Iteration = ( ) => {
143
+ if ( token == null ) {
144
+ // Timeout only must start at first iteration
145
+ token = Application . MainLoop . AddTimeout ( TimeSpan . FromMilliseconds ( ms ) , abortCallback ) ;
146
+ }
140
147
iterations ++ ;
141
148
output . WriteLine ( $ "'Generic' iteration { iterations } ") ;
142
149
// Stop if we run out of control...
@@ -146,16 +153,6 @@ public void Run_Generic ()
146
153
}
147
154
} ;
148
155
149
- var ms = 100 ;
150
- var abortCount = 0 ;
151
- Func < MainLoop , bool > abortCallback = ( MainLoop loop ) => {
152
- abortCount ++ ;
153
- output . WriteLine ( $ "'Generic' abortCount { abortCount } ") ;
154
- Application . RequestStop ( ) ;
155
- return false ;
156
- } ;
157
- var token = Application . MainLoop . AddTimeout ( TimeSpan . FromMilliseconds ( ms ) , abortCallback ) ;
158
-
159
156
Application . Top . KeyPress += ( object sender , KeyEventEventArgs args ) => {
160
157
// See #2474 for why this is commented out
161
158
Assert . Equal ( Key . CtrlMask | Key . Q , args . KeyEvent . Key ) ;
@@ -175,10 +172,7 @@ public void Run_Generic ()
175
172
Application . Shutdown ( ) ;
176
173
177
174
#if DEBUG_IDISPOSABLE
178
- foreach ( var inst in Responder . Instances ) {
179
- Assert . True ( inst . WasDisposed ) ;
180
- }
181
- Responder . Instances . Clear ( ) ;
175
+ Assert . Empty ( Responder . Instances ) ;
182
176
#endif
183
177
}
184
178
0 commit comments