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; IsStarted = true;
#if NETSTANDARD1_3 #if NETSTANDARD1_3
_logger.Info("WireMock.Net server using netstandard1.3"); _logger.Info("WireMock.Net server using netstandard1.3");
_host.Run(_cts.Token); _host.Run(_cts.Token);
#else #else
_logger.Info("WireMock.Net server using netstandard2.0"); _logger.Info("WireMock.Net server using netstandard2.0");
_host.Run(); _host.Run();
#endif #endif
} }
catch (Exception e) catch (Exception e)
{ {

View File

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

View File

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

View File

@@ -80,7 +80,7 @@ namespace WireMock.Owin
app.Use<WireMockMiddleware>(_options); app.Use<WireMockMiddleware>(_options);
_options.PostWireMockMiddlewareInit?.Invoke(app); _options.PostWireMockMiddlewareInit?.Invoke(app);
}; };
foreach (var url in Urls) foreach (var url in Urls)
{ {
servers.Add(WebApp.Start(url, startup)); servers.Add(WebApp.Start(url, startup));
@@ -104,7 +104,7 @@ namespace WireMock.Owin
{ {
IsStarted = false; IsStarted = false;
// Dispose all servers in finally block to make sure clean up allocated resource on error happening // 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. /// Gets a value indicating whether this server is started.
/// </summary> /// </summary>
[PublicAPI] [PublicAPI]
public bool IsStarted { get => _httpServer == null ? false : _httpServer.IsStarted; } public bool IsStarted => _httpServer != null && _httpServer.IsStarted;
/// <summary> /// <summary>
/// Gets the ports. /// Gets the ports.
@@ -200,7 +200,7 @@ namespace WireMock.Server
{ {
throw new TimeoutException($"Service start timed out after {TimeSpan.FromMilliseconds(settings.StartTimeout)}"); throw new TimeoutException($"Service start timed out after {TimeSpan.FromMilliseconds(settings.StartTimeout)}");
} }
ctsStartTimeout.Token.WaitHandle.WaitOne(100); ctsStartTimeout.Token.WaitHandle.WaitOne(ServerStartDelay);
} }
} }