Exemplo n.º 1
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure(LogRepository, new FileInfo("log4net.config"));

            if (WireMockServerSettingsParser.TryParseArguments(args, out var settings, new WireMockLog4NetLogger()))
            {
                return;
            }

            settings.Logger.Debug("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'")));

            _server = WireMockServer.Start(settings);

            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);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (WireMockServerSettingsParser.TryParseArguments(args, out var settings))
            {
                settings.Logger.Debug("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'")));

                WireMockServer.Start(settings);

                Console.WriteLine("Press any key to stop the server");
                Console.ReadKey();
            }
        }
Exemplo n.º 3
0
        public static WireMockServer Start([NotNull] string[] args, [CanBeNull] IWireMockLogger logger = null)
        {
            Check.NotNull(args, nameof(args));

            if (WireMockServerSettingsParser.TryParseArguments(args, out var settings, logger))
            {
                settings.Logger?.Debug("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'")));

                return(Start(settings));
            }

            return(null);
        }
Exemplo n.º 4
0
        static void Main(params string[] args)
        {
            XmlConfigurator.Configure(new FileInfo("log4net.config"));

            if (WireMockServerSettingsParser.TryParseArguments(args, out var settings))
            {
                settings.Logger.Debug("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'")));

                WireMockServer.Start(settings);

                Console.WriteLine("Press any key to stop the server");
                Console.ReadKey();
            }
        }
Exemplo n.º 5
0
        public static bool TryStart([NotNull] string[] args, out WireMockServer server, [CanBeNull] IWireMockLogger logger = null)
        {
            Check.NotNull(args, nameof(args));

            if (WireMockServerSettingsParser.TryParseArguments(args, out var settings, logger))
            {
                settings.Logger?.Info("Version [{0}]", Version);
                settings.Logger?.Debug("Server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'")));

                server = Start(settings);
                return(true);
            }

            server = null;
            return(false);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            XmlConfigurator.Configure(LogRepository, new FileInfo("log4net.config"));

            if (!WireMockServerSettingsParser.TryParseArguments(args, out var settings, new WireMockLog4NetLogger()))
            {
                return;
            }

            settings.Logger.Debug("WireMock.Net server arguments [{0}]", string.Join(", ", args.Select(a => $"'{a}'")));

            _server = WireMockServer.Start(settings);

            _server.Given(Request.Create().WithPath("/api/sap")
                          .UsingPost()
                          .WithBody((IBodyData xmlData) => {
                //xmlData is always null
                return(true);
            }))
            .RespondWith(Response.Create().WithStatusCode(System.Net.HttpStatusCode.OK));

            _server
            .Given(Request.Create()
                   .UsingAnyMethod())
            .RespondWith(Response.Create()
                         .WithTransformer()
                         .WithBody("{{Random Type=\"Integer\" Min=100 Max=999999}} {{DateTime.Now}} {{DateTime.Now \"yyyy-MMM\"}} {{String.Format (DateTime.Now) \"MMM-dd\"}}"));

            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);
            }
        }