public void describe_()
        {
            describe["#Escape"] = () =>
            {
                it["Wraps each argument in double quotes"] = () =>
                {
                    var args   = new[] { "/app", "", "/path with spaces/app" };
                    var result = ArgumentEscaper.Escape(args);
                    result.should_be("\"/app\" \"\" \"/path with spaces/app\"");
                };

                it["Escapes embedded double quotes"] = () =>
                {
                    var args   = new[] { "/path\"with\"quotes/app" };
                    var result = ArgumentEscaper.Escape(args);
                    result.should_be("\"/path\\\"with\\\"quotes/app\"");
                };

                it["Escapes embedded backslashes"] = () =>
                {
                    var args   = new[] { "{\"start_command\":\"start\\yo\"}" };
                    var result = ArgumentEscaper.Escape(args);
                    result.should_be("\"{\\\"start_command\\\":\\\"start\\\\yo\\\"}\"");
                };
            };
        }
示例#2
0
        private Process StartLauncher(params string[] args)
        {
            var startInfo = new ProcessStartInfo
            {
                Arguments              = ArgumentEscaper.Escape(args),
                FileName               = "Launcher.exe",
                RedirectStandardError  = true,
                RedirectStandardOutput = true,
                UseShellExecute        = false
            };
            var proc = Process.Start(startInfo);

            proc.should_not_be_null();
            proc.WaitForExit();
            return(proc);
        }