Ejemplo n.º 1
0
        public void pretty_print_xml_malformed_forgives()
        {
            var input  = "<root><hello>world</h></root>";
            var output = IorContentType.GetPrettyPrintedContent(IorMediaTypeCategory.Xml, input);

            output.Should().Be(input);
        }
Ejemplo n.º 2
0
        public void pretty_print_xml_with_doctype()
        {
            var input  = "<?xml version=\"1.0\"?><root><hello>world</hello></root>";
            var output = IorContentType.GetPrettyPrintedContent(IorMediaTypeCategory.Xml, input);

            output.Should().Be("<?xml version=\"1.0\"?>\r\n<root>\r\n  <hello>world</hello>\r\n</root>");
        }
Ejemplo n.º 3
0
        public void pretty_print_other()
        {
            var input  = "hello world";
            var output = IorContentType.GetPrettyPrintedContent(IorMediaTypeCategory.Text, input);

            output.Should().Be(input);
        }
Ejemplo n.º 4
0
        public void pretty_print_html()
        {
            var input  = "<html><body>hello world</body></html>";
            var output = IorContentType.GetPrettyPrintedContent(IorMediaTypeCategory.Html, input);

            output.Should().Be("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\r\n<html>\r\n  <head>\r\n    <title>\r\n    </title>\r\n  </head>\r\n  <body>\r\n    hello world\r\n  </body>\r\n</html>\r\n");
        }
Ejemplo n.º 5
0
        public void pretty_print_json_malformed_forgives()
        {
            var input  = "{ x: 23 + 3 }";
            var output = IorContentType.GetPrettyPrintedContent(IorMediaTypeCategory.Json, input);

            output.Should().Be(input);
        }
Ejemplo n.º 6
0
        public void pretty_print_json()
        {
            var input  = "{ x: 23 }";
            var output = IorContentType.GetPrettyPrintedContent(IorMediaTypeCategory.Json, input);

            output.Should().Be("{\r\n  \"x\": 23\r\n}");
        }
Ejemplo n.º 7
0
        private void initTxtRequestBody()
        {
            txtRequestBody.FindReplace.Window.Text = "Find / Replace - Request Body";
            txtRequestBody.Margins[0].Width        = 22;

            //note: style 32 is default style

            /*ns.StyleSetFore(1, ScintillaNET.Utilities.ColorToRgb(Color.Black));
             * ns.StyleSetFont(1, "Monospace");
             * ns.StyleSetSize(1, 12);
             * ns.setst*/

            var cm = txtRequestBody.ContextMenu;

            cm.MenuItems.Add("-");
            Action <ScintillaNET.Scintilla, IorMediaTypeCategory> format = (tb, hmtc) => {
                if (tb.Selection.Length > 0)
                {
                    var original = tb.Selection.Text;
                    var pretty   = IorContentType.GetPrettyPrintedContent(hmtc, tb.Selection.Text);
                    var startPos = tb.Selection.Start;
                    if (original != pretty)
                    {
                        tb.Selection.Text = pretty;
                        tb.GoTo.Position(startPos);
                    }
                }
                else
                {
                    var original = tb.Text;
                    var pretty   = IorContentType.GetPrettyPrintedContent(hmtc, tb.Text);
                    if (original != pretty)
                    {
                        tb.Text = pretty;
                        tb.GoTo.Position(0);
                    }
                }
            };

            var miFx = new MenuItem("Format XML", (s, ea) => { resetLogStats(); format(txtRequestBody, IorMediaTypeCategory.Xml); });

            miFx.Shortcut     = Shortcut.CtrlShiftX;
            miFx.ShowShortcut = true;
            cm.MenuItems.Add(miFx);

            var miFj = new MenuItem("Format JSON", (s, ea) => { resetLogStats(); format(txtRequestBody, IorMediaTypeCategory.Json); });

            miFj.Shortcut     = Shortcut.CtrlShiftJ;
            miFj.ShowShortcut = true;
            cm.MenuItems.Add(miFj);
        }