added WireMock.Net.StandAlone

This commit is contained in:
Stef Heyenrath
2017-02-05 18:43:01 +01:00
parent c987a59ca8
commit 51cc74ad20
9 changed files with 185 additions and 3 deletions

View File

@@ -0,0 +1,47 @@
using System;
using CommandLineParser.Arguments;
using CommandLineParser.Exceptions;
using WireMock.Server;
namespace WireMock.Net.StandAlone
{
public class Program
{
private class Options
{
[ValueArgument(typeof(string), 'u', "Urls", Description = "URL(s) to listen on", Optional = false, AllowMultiple = true)]
public string[] Urls;
[SwitchArgument('p', "AllowPartialMapping", true, Description = "Allow Partial Mapping (default set to true)", Optional = true)]
public bool AllowPartialMapping;
}
static void Main(params string[] args)
{
var options = new Options();
var parser = new CommandLineParser.CommandLineParser();
parser.ExtractArgumentAttributes(options);
parser.ParseCommandLine(args);
try
{
parser.ParseCommandLine(args);
var server = FluentMockServer.StartWithAdminInterface(options.Urls);
if (options.AllowPartialMapping)
server.AllowPartialMapping();
Console.WriteLine("WireMock.Net server listening at {0}", string.Join(" and ", server.Urls));
}
catch (CommandLineException e)
{
Console.WriteLine(e.Message);
parser.ShowUsage();
}
Console.WriteLine("Press any key to stop the server");
Console.ReadKey();
}
}
}