mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-24 09:45:01 +01:00
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using JetBrains.Annotations;
|
|
using System.Linq;
|
|
using WireMock.Logging;
|
|
using WireMock.Server;
|
|
using WireMock.Settings;
|
|
using WireMock.Validation;
|
|
|
|
namespace WireMock.Net.StandAlone
|
|
{
|
|
/// <summary>
|
|
/// The StandAloneApp
|
|
/// </summary>
|
|
public static class StandAloneApp
|
|
{
|
|
/// <summary>
|
|
/// Start WireMock.Net standalone Server based on the FluentMockServerSettings.
|
|
/// </summary>
|
|
/// <param name="settings">The FluentMockServerSettings</param>
|
|
[PublicAPI]
|
|
public static WireMockServer Start([NotNull] IWireMockServerSettings settings)
|
|
{
|
|
Check.NotNull(settings, nameof(settings));
|
|
|
|
var server = WireMockServer.Start(settings);
|
|
|
|
settings.Logger?.Info("WireMock.Net server listening at {0}", string.Join(",", server.Urls));
|
|
|
|
return server;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Start WireMock.Net standalone Server based on the commandline arguments.
|
|
/// </summary>
|
|
/// <param name="args">The commandline arguments</param>
|
|
/// <param name="logger">The logger</param>
|
|
[PublicAPI]
|
|
public static WireMockServer Start([NotNull] string[] args, [CanBeNull] IWireMockLogger logger = null)
|
|
{
|
|
Check.NotNull(args, nameof(args));
|
|
|
|
var settings = WireMockServerSettingsParser.ParseArguments(args, logger);
|
|
|
|
settings.Logger?.Debug("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'")));
|
|
|
|
return Start(settings);
|
|
}
|
|
}
|
|
} |