Small code refactor (#117)

This commit is contained in:
Stef Heyenrath
2018-04-05 20:51:10 +02:00
parent 2d2a2dd6fc
commit 4f294baff2
5 changed files with 5 additions and 14 deletions

View File

@@ -108,13 +108,12 @@ namespace WireMock.Owin
{
IsStarted = true;
#if NETSTANDARD1_3
_logger.Info("WireMock.Net server using netstandard1.3");
_logger.Info("WireMock.Net server using netstandard1.3");
_host.Run(_cts.Token);
#else
_logger.Info("WireMock.Net server using netstandard2.0");
_host.Run();
#endif
}
catch (Exception e)
{

View File

@@ -17,17 +17,11 @@ namespace WireMock.Owin
/// <summary>
/// Gets the urls.
/// </summary>
/// <value>
/// The urls.
/// </value>
List<string> Urls { get; }
/// <summary>
/// Gets the ports.
/// </summary>
/// <value>
/// The ports.
/// </value>
List<int> Ports { get; }
/// <summary>

View File

@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
// using System.IO;
using System.Linq;
// using System.Text;
using System.Threading.Tasks;
using WireMock.Util;
#if !NETSTANDARD

View File

@@ -80,7 +80,7 @@ namespace WireMock.Owin
app.Use<WireMockMiddleware>(_options);
_options.PostWireMockMiddlewareInit?.Invoke(app);
};
foreach (var url in Urls)
{
servers.Add(WebApp.Start(url, startup));
@@ -104,7 +104,7 @@ namespace WireMock.Owin
{
IsStarted = false;
// Dispose all servers in finally block to make sure clean up allocated resource on error happening
servers.ForEach((s) => s.Dispose());
servers.ForEach(s => s.Dispose());
}
}
}

View File

@@ -32,7 +32,7 @@ namespace WireMock.Server
/// Gets a value indicating whether this server is started.
/// </summary>
[PublicAPI]
public bool IsStarted { get => _httpServer == null ? false : _httpServer.IsStarted; }
public bool IsStarted => _httpServer != null && _httpServer.IsStarted;
/// <summary>
/// Gets the ports.
@@ -200,7 +200,7 @@ namespace WireMock.Server
{
throw new TimeoutException($"Service start timed out after {TimeSpan.FromMilliseconds(settings.StartTimeout)}");
}
ctsStartTimeout.Token.WaitHandle.WaitOne(100);
ctsStartTimeout.Token.WaitHandle.WaitOne(ServerStartDelay);
}
}