public WireMockServer Start() { var stubServer = StandAloneApp.Start(settings); stubServer.ReadAllMappings(); return(stubServer); }
static void Main(params string[] args) { StandAloneApp.Start(args); Console.WriteLine("Press any key to stop the server"); Console.ReadKey(); }
public MockService() { StandAloneApp.Start(new FluentMockServerSettings() { StartAdminInterface = true, Port = 1111 }); }
static void Main(string[] args) { XmlConfigurator.Configure(LogRepository, new FileInfo("log4net.config")); //_server = StandAloneApp.Start(args, new WireMockLog4NetLogger()); _server = StandAloneApp.Start(args, new WireMockConsoleLogger()); SetupRoutes(); //SetupProxy(); Console.WriteLine($"{DateTime.UtcNow} Press Ctrl+C to shut down"); Console.CancelKeyPress += (s, e) => { Stop("CancelKeyPress"); }; System.Runtime.Loader.AssemblyLoadContext.Default.Unloading += ctx => { Stop("AssemblyLoadContext.Default.Unloading"); }; while (true) { Console.WriteLine($"{DateTime.UtcNow} WireMock.Net server running : {_server.IsStarted}"); Thread.Sleep(sleepTime); } }
static void Main(params string[] args) { XmlConfigurator.Configure(new FileInfo("log4net.config")); StandAloneApp.Start(args); Console.WriteLine("Press any key to stop the server"); Console.ReadKey(); }
private static void Start(IWireMockLogger logger) { _server = StandAloneApp.Start(new FluentMockServerSettings { Urls = new[] { "http://*:9091/" }, StartAdminInterface = true, ReadStaticMappings = true, Logger = logger }); }
static void Main(string[] args) { var server = StandAloneApp.Start(args); server.Given(Request.Create()) .RespondWith(Response.Create().WithProxy("http://10.10.66.65")); Console.WriteLine("Press any key to stop the server"); Console.ReadKey(); }
public static IWireMockServer Start() { var settings = new WireMockServerSettings { Port = 5021, Logger = new WireMockConsoleLogger() }; var server = StandAloneApp.Start(settings); server.Given(Request.Create().WithPath(arg => Regex.IsMatch(arg, @"/demand/create")) .UsingGet()) .RespondWith(Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("create-demand.json")); server.Given(Request.Create().WithPath(arg => Regex.IsMatch(arg, @"/demand/create")) .WithParam(MatchLocationParam) .UsingGet()) .RespondWith(Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("create-demand-location.json")); server.Given(Request.Create().WithPath(arg => Regex.IsMatch(arg, @"/demand/create")) .UsingPost()) .RespondWith(Response.Create() .WithStatusCode(HttpStatusCode.Created) .WithBody($"'{Guid.NewGuid().ToString()}'") ); server.Given(Request.Create().WithPath(arg => Regex.IsMatch(arg, @"/locations")) .UsingGet()).RespondWith(Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("locations.json")); server.Given(Request.Create().WithPath(arg => Regex.IsMatch(arg, "/demand/aggregated/providers/\\d+")) .UsingGet()).RespondWith(Response.Create() .WithHeader("Content-Type", "application/json") .WithBodyFromFile("provider-employer-demand.json")); server.Given(Request.Create().WithPath(arg => Regex.IsMatch(arg, "/demand/aggregated/providers/\\d+")) .WithParam(MatchLocationParam) .UsingGet()).RespondWith(Response.Create() .WithHeader("Content-Type", "application/json") .WithBodyFromFile("provider-employer-demand-location.json")); return(server); }
public void Run() { _logger.LogInformation("WireMock.Net server starting"); StandAloneApp.Start(_settings); _logger.LogInformation($"WireMock.Net server settings {JsonConvert.SerializeObject(_settings)}"); while (true) { _logger.LogInformation("WireMock.Net server running"); Thread.Sleep(sleepTime); } }
static async Task Main(string[] args) { var server = StandAloneApp.Start(new FluentMockServerSettings { Port = 19019, StartAdminInterface = true, StartTimeout = 1000, MaxRequestLogCount = 100, RequestLogExpirationDuration = 6, Logger = new WireMockConsoleLogger() }); server .Given(Request .Create() .UsingGet()) .RespondWith(Response.Create() .WithHeader("Content-Type", "application/json") .WithBodyAsJson(new { result = "x" })); await Task.Delay(2000); var client = new HttpClient(); client.BaseAddress = new Uri(server.Urls[0]); var options = new ParallelOptions() { MaxDegreeOfParallelism = 2 }; var list = Enumerable.Range(1, 1000); Parallel.ForEach(list, options, async i => { string result = await client.GetStringAsync("/x"); System.Console.WriteLine(result); }); //for (int i = 0; i < 1000; i++) //{ // string result = await client.GetStringAsync("/x"); // System.Console.WriteLine(result); //} System.Console.WriteLine("Press any key to stop the server"); System.Console.ReadKey(); server.Stop(); }
static void Main(string[] args) { var server = StandAloneApp.Start(args); server.AllowPartialMapping(); server .Given(Request.Create() .WithPath("/oauth2/authorize") .WithHeader("Content-Type", "application/x-www-form-urlencoded") .UsingPost() .WithBody("grant_type=password;username=u;password=p;client_id=X;client_secret=P") ) .RespondWith(Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyAsJson(new { access_token = "AT", refresh_token = "RT" })); server .Given(Request.Create() .WithPath("/oauth2/token") .WithHeader("Content-Type", "application/x-www-form-urlencoded") .UsingPost() .WithBody("grant_type=refresh_token;refresh_token=RT;client_id=X;client_secret=P")) .RespondWith(Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyAsJson(new { access_token = "AT2" })); server .Given(Request.Create() .WithPath("/helloworld") .UsingGet() .WithHeader("Authorization", new RegexMatcher("^(?i)Bearer AT(2).$"))) .RespondWith(Response.Create() .WithStatusCode(200) .WithBody("hi")); // Create an implementation of the IFluentMockServerAdmin and pass in the base URL for the API. var api = RestClient.For <IFluentMockServerAdmin>("http://localhost:9090"); var mappings = api.GetMappingsAsync().Result; System.Console.WriteLine($"mappings = {JsonConvert.SerializeObject(mappings)}"); System.Console.WriteLine("Press any key to stop the server"); System.Console.ReadKey(); }
public CustomWebApplicationFactory() { var settings = new FluentMockServerSettings { AllowPartialMapping = false, StartAdminInterface = true, Port = 5001 }; WireMockServer = StandAloneApp.Start(settings); MongoDb = new MongoClient(Runner.ConnectionString).GetDatabase("ServiceName"); MessageReceiver = new MessageHelper(InMemoryBus); //mock consul request WireMockServer.Given(Request.Create().WithPath("/v1/kv/ServiceName") .UsingGet()) .RespondWith(WireMock.ResponseBuilders.Response.Create().WithNotFound()); }
public bool Start(HostControl hostControl) { _logger.Debug("Starting..."); var handleBarTransformers = new List <IHandleBarTransformer>(); try { var currentAssembly = Assembly.LoadFrom(_assemblyFile); var item = currentAssembly.GetType(_typeName); handleBarTransformers.Add((IHandleBarTransformer)Activator.CreateInstance(item)); } catch (Exception ex) { // ignored } var settings = new FluentMockServerSettings() { UseSSL = _useSsl, Port = _port, ReadStaticMappings = true, WatchStaticMappings = true, WatchStaticMappingsInSubdirectories = true, AllowPartialMapping = true, StartAdminInterface = true, Logger = _logger, FileSystemHandler = _fileHandler, HandlebarsRegistrationCallback = (a, b) => { foreach (var handleBarTransformer in handleBarTransformers) { a.RegisterHelper(handleBarTransformer.Name, handleBarTransformer.Render); } } }; _server = StandAloneApp.Start(settings); _logger.Debug("Started"); return(true); }
static void Main(string[] args) { Console.WriteLine("Starting WireMock."); var settings = new FluentMockServerSettings { ReadStaticMappings = true, WatchStaticMappings = true, StartAdminInterface = true, }; StandAloneApp.Start(settings); //var server = StandAloneApp.Start(settings); //server.ReadStaticMappings("CustomMappingFolder\\GetMapping"); //server.WatchStaticMappings("CustomMappingFolder\\GetMapping"); Console.WriteLine("WireMock started"); Console.ReadLine(); }
public static IWireMockServer Start() { var settings = new WireMockServerSettings { Port = 5016, Logger = new WireMockConsoleLogger() }; var server = StandAloneApp.Start(settings); AddLandingPageResponses(server); AddArticlePageResponses(server); AddHubPageResponses(server); AddMenuResponses(server); AddSiteMapResponses(server); AddSectorsResponses(server); AddTrainingCoursesResponses(server); AddVacanciesResponses(server); AddBannerResponses(server); return(server); }
public static void Main(string[] args) { var settings = new FluentMockServerSettings { AllowPartialMapping = false, StartAdminInterface = true, Port = 5555 }; var server = StandAloneApp.Start(settings); Console.WriteLine("FluentMockServer running at {0}", server.Ports.Single()); server.Given(Request.Create().UsingGet().WithPath("/api")) .RespondWith(Response.Create().WithBodyAsJson( new { Message = "Welcome to the stub API" })); BuildWebHost(args).Run(); }
public bool StartProcess() { Status = Lobby.EHostedGame.StoppedHosting; try { StandAloneApp.Start(); StandAloneApp.BeginErrorReadLine(); StandAloneApp.BeginOutputReadLine(); Status = Lobby.EHostedGame.StartedHosting; TimeStarted = new DateTime(DateTime.Now.ToUniversalTime().Ticks); return(true); } catch (Exception e) { Console.WriteLine(""); Console.WriteLine(StandAloneApp.StartInfo.FileName); Console.WriteLine(StandAloneApp.StartInfo.Arguments); Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } return(false); }
static void Main(string[] args) { server = StandAloneApp.Start(args); Console.WriteLine($"{DateTime.UtcNow} Press Ctrl+C to shut down"); System.Console.CancelKeyPress += (s, e) => { Stop("CancelKeyPress"); }; System.Runtime.Loader.AssemblyLoadContext.Default.Unloading += ctx => { Stop("AssemblyLoadContext.Default.Unloading"); }; while (true) { Console.WriteLine($"{DateTime.UtcNow} WireMock.Net server running"); Thread.Sleep(sleepTime); } }
public bool StartProcess(bool throwException = false) { Status = EHostedGame.StoppedHosting; try { StandAloneApp.Start(); Status = EHostedGame.StartedHosting; TimeStarted = new DateTime(DateTime.Now.ToUniversalTime().Ticks); return(true); } catch (Exception e) { if (throwException) { throw; } Console.WriteLine(""); Console.WriteLine(StandAloneApp.StartInfo.FileName); Console.WriteLine(StandAloneApp.StartInfo.Arguments); Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } return(false); }
public static IWireMockServer Start() { var settings = new WireMockServerSettings { Port = 5003, Logger = new WireMockConsoleLogger() }; var server = StandAloneApp.Start(settings); server.Given(Request.Create() .WithPath(s => Regex.IsMatch(s, "/trainingcourses/\\d+/providers/(?!(?:10000)$)\\d+$")) .WithParam(MatchLocationParamCoventry) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-provider-details-notfound.json")); server.Given(Request.Create() .WithPath(s => Regex.IsMatch(s, "/trainingcourses/\\d+/providers/10000$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-provider-unavailable.json")); server.Given(Request.Create() .WithPath(s => Regex.IsMatch(s, "/trainingcourses/\\d+/providers/(?!(?:10000)$)\\d+$")) .WithParam(MatchLocationParam) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-provider.json")); server.Given(Request.Create() .WithPath(s => Regex.IsMatch(s, "/trainingcourses/\\d+/providers/(?!(?:10000)$)\\d+$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-provider-nolocation.json")); server.Given(Request.Create() .WithPath(s => Regex.IsMatch(s, "/trainingcourses/(?!(?:102))\\d+/providers$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-providers-nolocation.json")); server.Given(Request.Create() .WithPath(s => Regex.IsMatch(s, "/trainingcourses/102/providers$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-providers-0-results.json")); server.Given(Request.Create() .WithPath(s => Regex.IsMatch(s, "/trainingcourses/(?!(?:102))\\d+/providers$")) .WithParam(MatchLocationParam) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-providers.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/trainingcourses/101$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-expired.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/trainingcourses/24$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-lastdatestarts.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/trainingcourses/333$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-regulated.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/trainingcourses/102$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-no-providers-at-location.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/trainingcourses/(?!(?:101|102|24|333)$)\\d+$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course.json")); server.Given(Request.Create().WithPath(IsLocation).UsingGet()).RespondWith(Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("locations.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/trainingcourses$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("courses.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/shortlist/users/\\S+$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("shortlist.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "shortlist$")) .UsingPost() ).RespondWith( Response.Create() .WithStatusCode(202) .WithBody($"'{Guid.NewGuid().ToString()}'")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "shortlist/users/")) .UsingDelete() ).RespondWith( Response.Create() .WithStatusCode(202)); return(server); }
public static IWireMockServer Start() { var settings = new WireMockServerSettings { Port = 5007, Logger = new WireMockConsoleLogger() }; var server = StandAloneApp.Start(settings); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/courses$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-list.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/courses/2/epaos$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-no-epaos.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/courses/14$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-integrated.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/courses/14/epaos$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-epaos-integrated.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/courses/(?!(?:14|2))\\d$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/courses/(?!(?:14|2))\\d/epaos$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-epaos.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/epaos/delivery-areas$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("delivery-areas.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/courses/\\d+/epaos/[eE][pP][aA]9999$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(404)); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/courses/(?!(?:14|2))\\d/epaos/[eE][pP][aA](?!(?:9999)$)[0-9]{4,9}$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-epao.json")); server.Given(Request.Create().WithPath(s => Regex.IsMatch(s, "/courses/14/epaos/[eE][pP][aA](?!(?:9999)$)[0-9]{4,9}$")) .UsingGet() ).RespondWith( Response.Create() .WithStatusCode(200) .WithHeader("Content-Type", "application/json") .WithBodyFromFile("course-epao-integrated.json")); return(server); }