public static FluentMockServer Start([NotNull] string[] args) { Check.NotNull(args, nameof(args)); Console.WriteLine("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'"))); var parser = new SimpleCommandLineParser(); parser.Parse(args); var settings = new FluentMockServerSettings { StartAdminInterface = parser.GetBoolValue("StartAdminInterface", true), ReadStaticMappings = parser.GetBoolValue("ReadStaticMappings"), AllowPartialMapping = parser.GetBoolValue("AllowPartialMapping", true), AdminUsername = parser.GetStringValue("AdminUsername"), AdminPassword = parser.GetStringValue("AdminPassword"), MaxRequestLogCount = parser.GetIntValue("MaxRequestLogCount"), RequestLogExpirationDuration = parser.GetIntValue("RequestLogExpirationDuration"), }; if (parser.Contains("Port")) { settings.Port = parser.GetIntValue("Port"); } else { settings.Urls = parser.GetValues("Urls", new[] { "http://*:9091/" }); } string proxyURL = parser.GetStringValue("ProxyURL"); if (!string.IsNullOrEmpty(proxyURL)) { settings.ProxyAndRecordSettings = new ProxyAndRecordSettings { Url = proxyURL, SaveMapping = parser.GetBoolValue("SaveMapping"), SaveMappingToFile = parser.GetBoolValue("SaveMappingToFile"), X509Certificate2ThumbprintOrSubjectName = parser.GetStringValue("X509Certificate2ThumbprintOrSubjectName") }; } Console.WriteLine("WireMock.Net server settings {0}", JsonConvert.SerializeObject(settings, Formatting.Indented)); FluentMockServer server = Start(settings); Console.WriteLine("WireMock.Net server listening at {0}", string.Join(" and ", server.Urls)); return(server); }
public static FluentMockServer Start([NotNull] string[] args, [CanBeNull] IWireMockLogger logger = null) { Check.NotNull(args, nameof(args)); var parser = new SimpleCommandLineParser(); parser.Parse(args); var settings = new FluentMockServerSettings { StartAdminInterface = parser.GetBoolValue("StartAdminInterface", true), ReadStaticMappings = parser.GetBoolValue("ReadStaticMappings"), WatchStaticMappings = parser.GetBoolValue("WatchStaticMappings"), AllowPartialMapping = parser.GetBoolValue("AllowPartialMapping"), AdminUsername = parser.GetStringValue("AdminUsername"), AdminPassword = parser.GetStringValue("AdminPassword"), MaxRequestLogCount = parser.GetIntValue("MaxRequestLogCount"), RequestLogExpirationDuration = parser.GetIntValue("RequestLogExpirationDuration"), AllowCSharpCodeMatcher = parser.GetBoolValue("AllowCSharpCodeMatcher"), }; if (logger != null) { settings.Logger = logger; } if (parser.GetStringValue("WireMockLogger") == "WireMockConsoleLogger") { settings.Logger = new WireMockConsoleLogger(); } if (parser.Contains("Port")) { settings.Port = parser.GetIntValue("Port"); } else { settings.Urls = parser.GetValues("Urls", new[] { "http://*:9091/" }); } string proxyURL = parser.GetStringValue("ProxyURL"); if (!string.IsNullOrEmpty(proxyURL)) { settings.ProxyAndRecordSettings = new ProxyAndRecordSettings { Url = proxyURL, SaveMapping = parser.GetBoolValue("SaveMapping"), SaveMappingToFile = parser.GetBoolValue("SaveMappingToFile"), ClientX509Certificate2ThumbprintOrSubjectName = parser.GetStringValue("ClientX509Certificate2ThumbprintOrSubjectName"), BlackListedHeaders = parser.GetValues("BlackListedHeaders"), BlackListedCookies = parser.GetValues("BlackListedCookies") }; } settings.Logger.Debug("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'"))); return(Start(settings)); }