Skip to content

Commit 31471ad

Browse files
committed
Update more tests to new pattern
1 parent 06d3467 commit 31471ad

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

src/Servers/IIS/IntegrationTesting.IIS/src/IISDeployer.cs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -361,20 +361,27 @@ private void Stop()
361361
{
362362
RetryServerManagerAction(serverManager =>
363363
{
364-
var site = serverManager.Sites.SingleOrDefault();
365-
if (site == null)
364+
foreach (var site in serverManager.Sites)
366365
{
367-
throw new InvalidOperationException("Site not found");
366+
if (site.State != ObjectState.Stopped && site.State != ObjectState.Stopping)
367+
{
368+
var state = site.Stop();
369+
Logger.LogInformation($"Stopping site, state: {state}");
370+
}
368371
}
369372

370-
if (site.State != ObjectState.Stopped && site.State != ObjectState.Stopping)
373+
foreach (var appPool in serverManager.ApplicationPools)
371374
{
372375
var state = site.Stop();
373376
Logger.LogInformation($"Stopping site, state: {state}");
377+
if (appPool.State != ObjectState.Stopped && appPool.State != ObjectState.Stopping)
378+
{
379+
var state = appPool.Stop();
380+
Logger.LogInformation($"Stopping pool, state: {state}");
381+
}
374382
}
375383

376-
var appPool = serverManager.ApplicationPools.SingleOrDefault();
377-
if (appPool == null)
384+
foreach (var site in serverManager.Sites)
378385
{
379386
throw new InvalidOperationException("Application pool not found");
380387
}
@@ -385,21 +392,24 @@ private void Stop()
385392
Logger.LogInformation($"Stopping pool, state: {state}");
386393
}
387394

388-
if (site.State != ObjectState.Stopped)
389-
{
390-
throw new InvalidOperationException("Site not stopped yet");
395+
if (site.State != ObjectState.Stopped)
396+
{
397+
throw new InvalidOperationException($"Site {site.Name} not stopped yet");
398+
}
391399
}
392400

393401
try
394402
{
395-
if (appPool.WorkerProcesses != null &&
396-
appPool.WorkerProcesses.Any(wp =>
397-
wp.State == WorkerProcessState.Running ||
398-
wp.State == WorkerProcessState.Stopping))
403+
foreach (var appPool in serverManager.ApplicationPools)
399404
{
400-
throw new InvalidOperationException("WorkerProcess not stopped yet");
405+
if (appPool.WorkerProcesses != null &&
406+
appPool.WorkerProcesses.Any(wp =>
407+
wp.State == WorkerProcessState.Running ||
408+
wp.State == WorkerProcessState.Stopping))
409+
{
410+
throw new InvalidOperationException("WorkerProcess not stopped yet");
411+
}
401412
}
402-
403413
}
404414
// If WAS was stopped for some reason appPool.WorkerProcesses
405415
// would throw UnauthorizedAccessException.

0 commit comments

Comments
 (0)