Exemplo n.º 1
0
        public void XmlFormattingTests_DoesNotIndentLiteralContent()
        {
            var input =
                "<test>" + Environment.NewLine +
                "<code>" + Environment.NewLine +
                "    Some code with." + Environment.NewLine +
                "   funny indenting" + Environment.NewLine +
                "" + Environment.NewLine +
                "  and a white line" + Environment.NewLine +
                "that should not change." + Environment.NewLine +
                "</code>" + Environment.NewLine +
                "</test>";

            var expected =
                "<test>" + Environment.NewLine +
                "    <code>" + Environment.NewLine +
                "    Some code with." + Environment.NewLine +
                "   funny indenting" + Environment.NewLine +
                "" + Environment.NewLine +
                "  and a white line" + Environment.NewLine +
                "that should not change." + Environment.NewLine +
                "    </code>" + Environment.NewLine +
                "</test>";

            Settings.Default.Formatting_CommentXmlValueIndent = 4;

            // First pass.
            var result = CommentFormatHelper.AssertEqualAfterFormat(input, expected);

            // Second pass.
            CommentFormatHelper.AssertEqualAfterFormat(result, expected);
        }
        public void SimpleFormattingTests_WrapsLinesAsExpected()
        {
            var input    = "Lorem ipsum dolor sit.";
            var expected = "Lorem ipsum\r\ndolor sit.";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 12);
        }
        public void XmlFormattingTests_RemoveSpaceFromInsideTags()
        {
            var input    = "<xml><see /></xml>";
            var expected = "<xml><see/></xml>";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.Xml.Default.SpaceSelfClosing = false);
        }
        public void XmlFormattingTests_RemoveSpaceFromTagContent()
        {
            var input    = "<xml> <c> test </c> </xml>";
            var expected = "<xml><c>test</c></xml>";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.Xml.Default.SpaceContent = false);
        }
        public void SimpleFormattingTests_RemoveBlankLinesBefore()
        {
            var input    = "\r\n\r\nLorem ipsum dolor sit amet.";
            var expected = "Lorem ipsum dolor sit amet.";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected);
        }
Exemplo n.º 6
0
        public void XmlFormattingTests_KeepCodeFormatting()
        {
            var input =
                "<test><code>" + Environment.NewLine +
                "some" + Environment.NewLine +
                "  code" + Environment.NewLine +
                "stuff" + Environment.NewLine +
                "</code></test>";

            var expected =
                "<test>" + Environment.NewLine +
                "<code>" + Environment.NewLine +
                "some" + Environment.NewLine +
                "  code" + Environment.NewLine +
                "stuff" + Environment.NewLine +
                "</code>" + Environment.NewLine +
                "</test>";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, new CodeCommentOptions(Settings.Default)
            {
                WrapAtColumn       = 100,
                XmlSplitSummaryTag = false,
                XmlSplitAllTags    = false
            });
        }
Exemplo n.º 7
0
        public void SimpleFormatWithPrefixTests_TrimsTrailingSpace()
        {
            var input    = "//   ";
            var expected = "//";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//");
        }
        public void ListFormattingTests_XmlListWithHeader()
        {
            var input =
                "Some text before." + Environment.NewLine +
                "<list type=\"bullet\">" + Environment.NewLine +
                "   <listheader>" + Environment.NewLine +
                "       <term>header term</term>" + Environment.NewLine +
                "       <description>description</description>" + Environment.NewLine +
                "   </listheader>" + Environment.NewLine +
                "   <item>" + Environment.NewLine +
                "       <term>item term</term>" + Environment.NewLine +
                "       <description>description</description>" + Environment.NewLine +
                "   </item>" + Environment.NewLine +
                "</list>" + Environment.NewLine +
                "Some trailing text.";

            var expected =
                "Some text before." + Environment.NewLine +
                "<list type=\"bullet\">" + Environment.NewLine +
                "<listheader>" + Environment.NewLine +
                "<term>header term</term>" + Environment.NewLine +
                "<description>description</description>" + Environment.NewLine +
                "</listheader>" + Environment.NewLine +
                "<item>" + Environment.NewLine +
                "<term>item term</term>" + Environment.NewLine +
                "<description>description</description>" + Environment.NewLine +
                "</item>" + Environment.NewLine +
                "</list>" + Environment.NewLine +
                "Some trailing text.";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected);
        }
Exemplo n.º 9
0
        public void XmlFormattingTests_BreakSummaryTags()
        {
            var input    = "<summary></summary><returns></returns>";
            var expected = "<summary>" + Environment.NewLine + "</summary>" + Environment.NewLine + "<returns></returns>";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected);
        }
        public void SimpleFormattingTests_RemovesLineBreaks()
        {
            var input    = "Lorem ipsum\r\ndolor sit amet.";
            var expected = "Lorem ipsum dolor sit amet.";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected);
        }
        public void XmlFormattingTests_TagCase_Upper()
        {
            var input    = "<Xml></Xml>";
            var expected = "<XML></XML>";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.Xml.Default.Case = XmlTagCase.UpperCase);
        }
Exemplo n.º 12
0
        public void XmlFormattingTests_DoesIndentAfterLiteralContent()
        {
            var input =
                "<example>" + Environment.NewLine +
                "Example usage :" + Environment.NewLine +
                "<code source=\"..\\MyExamples\\Examples.cs\" region=\"Example1\" language=\"cs\"/>" + Environment.NewLine +
                "Example usage with a location parameter and a location function:" + Environment.NewLine +
                "<code source=\"..\\MyExamples\\Examples.cs\" region=\"Example2\" language=\"cs\"/>" + Environment.NewLine +
                "And some final text that should also be formatted." + Environment.NewLine +
                "</example>";

            var expected =
                "<example>" + Environment.NewLine +
                "    Example usage :" + Environment.NewLine +
                "    <code source=\"..\\MyExamples\\Examples.cs\" region=\"Example1\" language=\"cs\"/>" + Environment.NewLine +
                "    Example usage with a location parameter and a location function:" + Environment.NewLine +
                "    <code source=\"..\\MyExamples\\Examples.cs\" region=\"Example2\" language=\"cs\"/>" + Environment.NewLine +
                "    And some final text that should also be formatted." + Environment.NewLine +
                "</example>";

            Settings.Default.Formatting_CommentXmlValueIndent      = 4;
            Settings.Default.Formatting_CommentXmlKeepTagsTogether = true;

            // First pass.
            var result = CommentFormatHelper.AssertEqualAfterFormat(input, expected);

            // Second pass.
            CommentFormatHelper.AssertEqualAfterFormat(result, expected);
        }
Exemplo n.º 13
0
        public void XmlFormattingTests_InterpunctionNoSpacing()
        {
            var input = "<test>Line with <interpunction/>.</test>";

            Settings.Default.Formatting_CommentXmlSpaceSingleTags = false;

            CommentFormatHelper.AssertEqualAfterFormat(input);
        }
Exemplo n.º 14
0
        public void XmlFormattingTests_DoNotAutoExpandTags()
        {
            var input = "<summary/>";

            Settings.Default.Formatting_CommentXmlSplitSummaryTagToMultipleLines = false;

            CommentFormatHelper.AssertEqualAfterFormat(input);
        }
Exemplo n.º 15
0
        public void SimpleFormattingTests_DoesNotWrapShortLines()
        {
            var input = "Lorem ipsum dolor sit amet.";

            CommentFormatHelper.AssertEqualAfterFormat(input, new CodeCommentOptions()
            {
                WrapAtColumn = 100
            });
        }
Exemplo n.º 16
0
        public void SimpleFormatWithPrefixTests_KeepsPrefix()
        {
            var input    = "// Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
            var expected =
                "// Lorem ipsum dolor sit amet," + Environment.NewLine +
                "// consectetur adipiscing elit.";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//", o => o.WrapColumn = 40);
        }
Exemplo n.º 17
0
        public void SimpleFormatWithPrefixTests_NoTrailingWhitespaceOnEmptyLine()
        {
            var input =
                "// Lorem ipsum dolor sit amet." + Environment.NewLine +
                "//" + Environment.NewLine +
                "// Consectetur adipiscing elit.";

            CommentFormatHelper.AssertEqualAfterFormat(input, input, "//", o => o.WrapColumn = 40);
        }
Exemplo n.º 18
0
        public void SimpleFormattingTests_PreservesSingleBlankLine()
        {
            var input = "Lorem ipsum\r\n\r\ndolor sit amet.";

            CommentFormatHelper.AssertEqualAfterFormat(input, new CodeCommentOptions()
            {
                WrapAtColumn = 100,
            });
        }
        public void XmlFormattingTests_AllRootLevelTagsOnNewLine()
        {
            var input    = "<tag1>abc</tag1><tag2>abc</tag2>";
            var expected =
                "<tag1>abc</tag1>" + Environment.NewLine +
                "<tag2>abc</tag2>";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected);
        }
Exemplo n.º 20
0
        public void XmlFormattingTests_AllRootLevelTagsOnNewLine()
        {
            var input    = "<summary>abc</summary><returns>abc</returns>";
            var expected = "<summary>abc</summary>" + Environment.NewLine + "<returns>abc</returns>";

            Settings.Default.Formatting_CommentXmlSplitSummaryTagToMultipleLines = false;

            CommentFormatHelper.AssertEqualAfterFormat(input, expected);
        }
Exemplo n.º 21
0
        public void XmlFormattingTests_RemoveSpaceFromTagContent()
        {
            var input    = "<summary> <c> test </c> </summary>";
            var expected = "<summary><c>test</c></summary>";

            Settings.Default.Formatting_CommentXmlSplitSummaryTagToMultipleLines = false;

            CommentFormatHelper.AssertEqualAfterFormat(input, expected);
        }
Exemplo n.º 22
0
        public void XmlFormattingTests_TagNameKeepCase()
        {
            var input = "<Summary></Summary>";

            Settings.Default.Formatting_CommentXmlSplitSummaryTagToMultipleLines = false;
            Settings.Default.Formatting_CommentXmlTagsToLowerCase = false;

            CommentFormatHelper.AssertEqualAfterFormat(input);
        }
Exemplo n.º 23
0
        public void SimpleFormattingTests_SkipWrapOnLastWord()
        {
            var input    = "Lorem ipsum dolor sit amet.";
            var expected = "Lorem ipsum\r\ndolor sit amet.";

            Settings.Default.Formatting_CommentWrapColumn         = 12;
            Settings.Default.Formatting_CommentSkipWrapOnLastWord = true;

            CommentFormatHelper.AssertEqualAfterFormat(input, expected);
        }
Exemplo n.º 24
0
        public void XmlFormattingTests_AddSpaceToInsideTags()
        {
            var input    = "<summary><see/></summary>";
            var expected = "<summary><see /></summary>";

            Settings.Default.Formatting_CommentXmlSplitSummaryTagToMultipleLines = false;
            Settings.Default.Formatting_CommentXmlSpaceSingleTags = true;

            CommentFormatHelper.AssertEqualAfterFormat(input, expected);
        }
Exemplo n.º 25
0
        public void SimpleFormattingTests_RemoveBlankLinesBefore()
        {
            var input    = "\r\n\r\nLorem ipsum dolor sit amet.";
            var expected = "Lorem ipsum dolor sit amet.";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, new CodeCommentOptions(Settings.Default)
            {
                WrapAtColumn = 100,
            });
        }
        public void XmlFormattingTests_AddSpaceToInsideTags()
        {
            var input    = "<xml><see/></xml>";
            var expected = "<xml><see /></xml>";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, o =>
            {
                o.Xml.Default.SpaceSelfClosing = true;
            });
        }
        public void XmlFormattingTests_AddSpaceToTagContent()
        {
            var input    = "<xml><c>test</c></xml>";
            var expected = "<xml> <c> test </c> </xml>";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, o =>
            {
                o.Xml.Default.SpaceContent = true;
            });
        }
Exemplo n.º 28
0
        public void XmlFormattingTests_BreakTagsWhenContainsParagraphs()
        {
            var input    = "<example><para>test</para></example>";
            var expected =
                "<example>" + Environment.NewLine +
                "<para>test</para>" + Environment.NewLine +
                "</example>";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected);
        }
Exemplo n.º 29
0
        public void SimpleFormattingTests_WrapsLinesAsExpected()
        {
            var input    = "Lorem ipsum dolor sit.";
            var expected = "Lorem ipsum\r\ndolor sit.";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, new CodeCommentOptions()
            {
                WrapAtColumn = 12,
            });
        }
Exemplo n.º 30
0
        public void SimpleFormattingTests_RemovesLineBreaks()
        {
            var input    = "Lorem ipsum\r\ndolor sit amet.";
            var expected = "Lorem ipsum dolor sit amet.";

            CommentFormatHelper.AssertEqualAfterFormat(input, expected, new CodeCommentOptions()
            {
                WrapAtColumn = 100,
            });
        }