@@ -32,7 +32,7 @@ public static void IdCannotBeReused()
32
32
database . Register ( DummyAgent ) ;
33
33
Assert . That ( ( ) => database . AddAgent ( DummyAgentId , DummyProcess ) , Throws . ArgumentException . With . Property ( "ParamName" ) . EqualTo ( "agentId" ) ) ;
34
34
35
- database . MarkTerminated ( DummyAgentId ) ;
35
+ database . MarkProcessTerminated ( DummyProcess ) ;
36
36
Assert . That ( ( ) => database . AddAgent ( DummyAgentId , DummyProcess ) , Throws . ArgumentException . With . Property ( "ParamName" ) . EqualTo ( "agentId" ) ) ;
37
37
}
38
38
@@ -60,7 +60,7 @@ public static void AgentMustNotRegisterAfterTerminating()
60
60
var database = new AgentStore ( ) ;
61
61
62
62
database . AddAgent ( DummyAgentId , DummyProcess ) ;
63
- database . MarkTerminated ( DummyAgentId ) ;
63
+ database . MarkProcessTerminated ( DummyProcess ) ;
64
64
Assert . That ( ( ) => database . Register ( DummyAgent ) , Throws . ArgumentException . With . Property ( "ParamName" ) . EqualTo ( "agent" ) ) ;
65
65
}
66
66
@@ -69,7 +69,8 @@ public static void AgentMustBeStartedBeforeTerminating()
69
69
{
70
70
var database = new AgentStore ( ) ;
71
71
72
- Assert . That ( ( ) => database . MarkTerminated ( DummyAgentId ) , Throws . ArgumentException . With . Property ( "ParamName" ) . EqualTo ( "agentId" ) ) ;
72
+ Assert . That ( ( ) => database . MarkProcessTerminated ( DummyProcess ) ,
73
+ Throws . Exception . TypeOf < NUnitEngineException > ( ) . With . Message . EqualTo ( "Process terminated without registering an agent." ) ) ;
73
74
}
74
75
75
76
[ Test ]
@@ -107,7 +108,7 @@ public static void AgentIsNotReadyWhenTerminated()
107
108
108
109
database . AddAgent ( DummyAgentId , DummyProcess ) ;
109
110
database . Register ( DummyAgent ) ;
110
- database . MarkTerminated ( DummyAgentId ) ;
111
+ database . MarkProcessTerminated ( DummyProcess ) ;
111
112
Assert . That ( database . IsReady ( DummyAgentId , out _ ) , Is . False ) ;
112
113
}
113
114
@@ -147,7 +148,7 @@ public static void AgentIsNotRunningWhenTerminated()
147
148
148
149
database . AddAgent ( DummyAgentId , DummyProcess ) ;
149
150
database . Register ( DummyAgent ) ;
150
- database . MarkTerminated ( DummyAgentId ) ;
151
+ database . MarkProcessTerminated ( DummyProcess ) ;
151
152
Assert . That ( database . IsAgentProcessActive ( DummyAgentId , out _ ) , Is . False ) ;
152
153
}
153
154
@@ -169,11 +170,13 @@ public static void ConcurrentOperationsDoNotCorruptState()
169
170
Assert . That ( database . IsAgentProcessActive ( id , out _ ) , Is . True ) ;
170
171
Assert . That ( database . IsReady ( id , out _ ) , Is . False ) ;
171
172
173
+ // Pretend that the agent process started and registered
172
174
database . Register ( new DummyTestAgent ( id ) ) ;
173
175
Assert . That ( database . IsAgentProcessActive ( id , out _ ) , Is . True ) ;
174
176
Assert . That ( database . IsReady ( id , out _ ) , Is . True ) ;
175
177
176
- database . MarkTerminated ( id ) ;
178
+ //database.MarkProcessTerminated(DummyProcess);
179
+ database . MarkAgentTerminated ( id ) ;
177
180
Assert . That ( database . IsAgentProcessActive ( id , out _ ) , Is . False ) ;
178
181
Assert . That ( database . IsReady ( id , out _ ) , Is . False ) ;
179
182
}
@@ -210,6 +213,35 @@ private static void RunActionConcurrently(Action action, int threadCount)
210
213
if ( exceptions . Count != 0 )
211
214
throw exceptions [ 0 ] ;
212
215
}
216
+
217
+ #region Nested DummyTestAgent Class
218
+
219
+ private sealed class DummyTestAgent : ITestAgent
220
+ {
221
+ public DummyTestAgent ( Guid id )
222
+ {
223
+ Id = id ;
224
+ }
225
+
226
+ public Guid Id { get ; }
227
+
228
+ public ITestEngineRunner CreateRunner ( TestPackage package )
229
+ {
230
+ throw new NotImplementedException ( ) ;
231
+ }
232
+
233
+ public bool Start ( )
234
+ {
235
+ throw new NotImplementedException ( ) ;
236
+ }
237
+
238
+ public void Stop ( )
239
+ {
240
+ throw new NotImplementedException ( ) ;
241
+ }
242
+ }
243
+
244
+ #endregion
213
245
}
214
246
}
215
247
#endif
0 commit comments