mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-19 08:37:23 +01:00
Add Port and Url property to WireMockServer (#740)
This commit is contained in:
@@ -241,8 +241,8 @@
|
||||
<Reference Include="System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.IO.Pipelines.4.5.3\lib\netstandard2.0\System.IO.Pipelines.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Linq.Dynamic.Core, Version=1.2.16.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Linq.Dynamic.Core.1.2.16\lib\net46\System.Linq.Dynamic.Core.dll</HintPath>
|
||||
<Reference Include="System.Linq.Dynamic.Core, Version=1.2.18.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Linq.Dynamic.Core.1.2.18\lib\net46\System.Linq.Dynamic.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<package id="System.ComponentModel.Annotations" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.IO.Pipelines" version="4.5.3" targetFramework="net472" />
|
||||
<package id="System.Linq.Dynamic.Core" version="1.2.16" targetFramework="net472" />
|
||||
<package id="System.Linq.Dynamic.Core" version="1.2.18" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net472" />
|
||||
|
||||
@@ -225,8 +225,8 @@
|
||||
<Reference Include="System.IO.Pipelines, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.IO.Pipelines.4.5.2\lib\netstandard2.0\System.IO.Pipelines.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Linq.Dynamic.Core, Version=1.2.16.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Linq.Dynamic.Core.1.2.16\lib\net46\System.Linq.Dynamic.Core.dll</HintPath>
|
||||
<Reference Include="System.Linq.Dynamic.Core, Version=1.2.18.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Linq.Dynamic.Core.1.2.18\lib\net46\System.Linq.Dynamic.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Memory.4.5.1\lib\netstandard2.0\System.Memory.dll</HintPath>
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net461" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="4.5.0" targetFramework="net461" />
|
||||
<package id="System.IO.Pipelines" version="4.5.2" targetFramework="net461" />
|
||||
<package id="System.Linq.Dynamic.Core" version="1.2.16" targetFramework="net461" />
|
||||
<package id="System.Linq.Dynamic.Core" version="1.2.18" targetFramework="net461" />
|
||||
<package id="System.Memory" version="4.5.1" targetFramework="net461" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net461" />
|
||||
<package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net461" />
|
||||
|
||||
@@ -38,11 +38,21 @@ namespace WireMock.Server
|
||||
/// </summary>
|
||||
List<int> Ports { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first port.
|
||||
/// </summary>
|
||||
int Port { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the urls.
|
||||
/// </summary>
|
||||
string[] Urls { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first url.
|
||||
/// </summary>
|
||||
string Url { get; }
|
||||
|
||||
//ConcurrentDictionary<string, ScenarioState> Scenarios { get; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using Stef.Validation;
|
||||
using WireMock.Admin.Mappings;
|
||||
using WireMock.Authentication;
|
||||
using WireMock.Exceptions;
|
||||
@@ -18,7 +19,6 @@ using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseProviders;
|
||||
using WireMock.Serialization;
|
||||
using WireMock.Settings;
|
||||
using Stef.Validation;
|
||||
|
||||
namespace WireMock.Server
|
||||
{
|
||||
@@ -40,14 +40,22 @@ namespace WireMock.Server
|
||||
[PublicAPI]
|
||||
public bool IsStarted => _httpServer != null && _httpServer.IsStarted;
|
||||
|
||||
/// <inheritdoc cref="IWireMockServer.Ports" />
|
||||
/// <inheritdoc />
|
||||
[PublicAPI]
|
||||
public List<int> Ports { get; }
|
||||
|
||||
/// <inheritdoc cref="IWireMockServer.Urls" />
|
||||
/// <inheritdoc />
|
||||
[PublicAPI]
|
||||
public int Port => Ports?.FirstOrDefault() ?? default(int);
|
||||
|
||||
/// <inheritdoc />
|
||||
[PublicAPI]
|
||||
public string[] Urls { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[PublicAPI]
|
||||
public string Url => Urls?.FirstOrDefault();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the mappings.
|
||||
/// </summary>
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="SimMetrics.Net" Version="1.0.5" />
|
||||
<PackageReference Include="Stef.Validation" Version="0.1.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.17" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.18" />
|
||||
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.14" />
|
||||
<PackageReference Include="JmesPath.Net" Version="1.0.125" />
|
||||
<PackageReference Include="AnyOf" Version="0.3.0" />
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<!--<PackageReference Include="OpenCover" Version="4.7.922" />-->
|
||||
<!--<PackageReference Include="ReportGenerator" Version="4.8.1" />-->
|
||||
<PackageReference Include="SimMetrics.Net" Version="1.0.5" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.17" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.18" />
|
||||
<!--<PackageReference Include="StrongNamer" Version="0.2.5" />-->
|
||||
<PackageReference Include="AnyOf" Version="0.3.0" />
|
||||
<!--<PackageReference Include="TinyMapper" Version="3.0.3" />-->
|
||||
|
||||
@@ -324,7 +324,7 @@ namespace WireMock.Net.Tests
|
||||
Check.That(mappings).HasSize(2);
|
||||
|
||||
// when
|
||||
var response = await new HttpClient().GetAsync("http://localhost:" + server.Ports[0] + "/1").ConfigureAwait(false);
|
||||
var response = await new HttpClient().GetAsync("http://localhost:" + server.Port + "/1").ConfigureAwait(false);
|
||||
|
||||
// then
|
||||
Check.That((int)response.StatusCode).IsEqualTo(400);
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace WireMock.Net.Tests
|
||||
var server = WireMockServer.StartWithAdminInterface();
|
||||
|
||||
// Act
|
||||
var response = await new HttpClient().PostAsync($"{server.Urls[0]}/__admin/mappings", stringContent).ConfigureAwait(false);
|
||||
var response = await new HttpClient().PostAsync($"{server.Url}/__admin/mappings", stringContent).ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
Check.That(response.StatusCode).Equals(HttpStatusCode.Created);
|
||||
|
||||
Reference in New Issue
Block a user