StandAloneApp: FluentMockServerSettings

This commit is contained in:
Stef Heyenrath
2017-06-15 13:40:42 +02:00
parent 85e51b6240
commit c29b88eb43
4 changed files with 32 additions and 8 deletions

View File

@@ -5,6 +5,8 @@ using CommandLineParser.Arguments;
using CommandLineParser.Exceptions;
using WireMock.Server;
using WireMock.Settings;
using WireMock.Validation;
using JetBrains.Annotations;
namespace WireMock.Net.StandAlone
{
@@ -37,12 +39,32 @@ namespace WireMock.Net.StandAlone
public string X509Certificate2Filename { get; set; }
}
/// <summary>
/// Start WireMock.Net standalone bases on the FluentMockServerSettings.
/// </summary>
/// <param name="settings">The FluentMockServerSettings</param>
/// <param name="allowPartialMapping">Allow Partial Mapping (default set to false).</param>
public static FluentMockServer Start([NotNull] FluentMockServerSettings settings, bool allowPartialMapping = false)
{
Check.NotNull(settings, nameof(settings));
var server = FluentMockServer.Start(settings);
if (allowPartialMapping)
{
server.AllowPartialMapping();
}
return server;
}
/// <summary>
/// Start WireMock.Net standalone bases on the commandline arguments.
/// </summary>
/// <param name="args">The commandline arguments</param>
public static FluentMockServer Start(string[] args)
public static FluentMockServer Start([NotNull] string[] args)
{
Check.NotNull(args, nameof(args));
var options = new Options();
var parser = new CommandLineParser.CommandLineParser();
parser.ExtractArgumentAttributes(options);
@@ -73,11 +95,7 @@ namespace WireMock.Net.StandAlone
};
}
var server = FluentMockServer.Start(settings);
if (options.AllowPartialMapping)
{
server.AllowPartialMapping();
}
FluentMockServer server = Start(settings, options.AllowPartialMapping);
Console.WriteLine("WireMock.Net server listening at {0}", string.Join(" and ", server.Urls));

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Lightweight StandAlone Http Mocking Server for .Net.</Description>
<AssemblyTitle>WireMock.Net.StandAlone</AssemblyTitle>
<Version>1.0.1.0</Version>
<Version>1.0.2.0</Version>
<Authors>Stef Heyenrath</Authors>
<TargetFrameworks>net45;net452;net46;netstandard1.3</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -27,6 +27,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="10.4.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="CommandLineArgumentsParser" Version="3.0.11" />
</ItemGroup>

View File

@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("WireMock.Net.StandAlone")]

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape.</Description>
<AssemblyTitle>WireMock.Net</AssemblyTitle>
<Version>1.0.2.1</Version>
<Version>1.0.2.2</Version>
<Authors>Alexandre Victoor;Stef Heyenrath</Authors>
<TargetFrameworks>net45;net452;net46;netstandard1.3</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>