public void Options_Deserialize_OverrideAll()
        {
            var options = new TSqlStandardFormatterOptions(
                "IndentString=    "
                + ",SpacesPerTab=2"
                + ",MaxLineWidth=100"
                + ",ExpandCommaLists=false"
                + ",TrailingCommas=True"
                + ",SpaceAfterExpandedComma=true"
                + ",ExpandBooleanExpressions=False"
                + ",ExpandCaseStatements=false"
                + ",ExpandBetweenConditions=false"
                + ",BreakJoinOnSections=true"
                + ",UppercaseKeywords=false"
                + ",HTMLColoring=true"
                + ",KeywordStandardization=true"
            );

            Assert.AreEqual("    ", options.IndentString);
            Assert.AreEqual(2, options.SpacesPerTab);
            Assert.AreEqual(100, options.MaxLineWidth);
            Assert.IsFalse(options.ExpandCommaLists);
            Assert.IsTrue(options.TrailingCommas);
            Assert.IsTrue(options.SpaceAfterExpandedComma);
            Assert.IsFalse(options.ExpandBooleanExpressions);
            Assert.IsFalse(options.ExpandCaseStatements);
            Assert.IsFalse(options.ExpandBetweenConditions);
            Assert.IsTrue(options.BreakJoinOnSections);
            Assert.IsFalse(options.UppercaseKeywords);
            Assert.IsTrue(options.HTMLColoring);
            Assert.IsTrue(options.KeywordStandardization);
        }
コード例 #2
0
        public TSqlStandardFormatter(TSqlStandardFormatterOptions options)
        {
            if (options == null)
                throw new ArgumentNullException("options");

            Options = options;

            if (options.KeywordStandardization)
                KeywordMapping = StandardKeywordRemapping.Instance;
            ErrorOutputPrefix = Interfaces.MessagingConstants.FormatErrorDefaultMessage + Environment.NewLine;
        }
コード例 #3
0
 private TSqlStandardFormatter GetFormatter(string configString)
 {
     TSqlStandardFormatter outFormatter;
     if (!_formatters.TryGetValue(configString, out outFormatter))
     {
         //defaults are as per the object, except disabling colorized/htmlified output
         var options = new TSqlStandardFormatterOptions(configString);
         options.HTMLColoring = false;
         outFormatter = new TSqlStandardFormatter(options);
     }
     return outFormatter;
 }
        public void Options_New_DefaultsToOriginalOptions()
        {
            var options = new TSqlStandardFormatterOptions();

            Assert.AreEqual("\t", options.IndentString);
            Assert.AreEqual(4, options.SpacesPerTab);
            Assert.AreEqual(999, options.MaxLineWidth);
            Assert.IsTrue(options.ExpandCommaLists);
            Assert.IsFalse(options.TrailingCommas);
            Assert.IsFalse(options.SpaceAfterExpandedComma);
            Assert.IsTrue(options.ExpandBooleanExpressions);
            Assert.IsTrue(options.ExpandCaseStatements);
            Assert.IsTrue(options.ExpandBetweenConditions);
            Assert.IsFalse(options.BreakJoinOnSections);
            Assert.IsTrue(options.UppercaseKeywords);
            Assert.IsFalse(options.HTMLColoring);
            Assert.IsFalse(options.KeywordStandardization);
        }
コード例 #5
0
        public TSqlStandardFormatter(string indentString, int spacesPerTab, int maxLineWidth, bool expandCommaLists, bool trailingCommas, bool spaceAfterExpandedComma, bool expandBooleanExpressions, bool expandCaseStatements, bool expandBetweenConditions, bool breakJoinOnSections, bool uppercaseKeywords, bool htmlColoring, bool keywordStandardization)
        {
            Options = new TSqlStandardFormatterOptions
                {
                    IndentString = indentString,
                    SpacesPerTab = spacesPerTab,
                    MaxLineWidth = maxLineWidth,
                    ExpandCommaLists = expandCommaLists,
                    TrailingCommas = trailingCommas,
                    SpaceAfterExpandedComma = spaceAfterExpandedComma,
                    ExpandBooleanExpressions = expandBooleanExpressions,
                    ExpandBetweenConditions = expandBetweenConditions,
                    ExpandCaseStatements = expandCaseStatements,
                    UppercaseKeywords = uppercaseKeywords,
                    BreakJoinOnSections = breakJoinOnSections,
                    HTMLColoring = htmlColoring,
                    KeywordStandardization = keywordStandardization
                };

            if (keywordStandardization)
                KeywordMapping = StandardKeywordRemapping.Instance;
            ErrorOutputPrefix = Interfaces.MessagingConstants.FormatErrorDefaultMessage + Environment.NewLine;
        }
        public void Options_Deserialize_RoundTrip()
        {
            var expected = new TSqlStandardFormatterOptions
                {
                    IndentString = "  ",
                    SpacesPerTab = 2,
                    MaxLineWidth = 100,
                    ExpandCommaLists = false,
                    TrailingCommas = true,
                    SpaceAfterExpandedComma = true,
                    ExpandBooleanExpressions = false,
                    ExpandCaseStatements = false,
                    ExpandBetweenConditions = false,
                    BreakJoinOnSections = true,
                    UppercaseKeywords = false,
                    HTMLColoring = true,
                    KeywordStandardization = true
                };

            var serializedString = expected.ToSerializedString();

            var actual = new TSqlStandardFormatterOptions(serializedString);

            Assert.AreEqual(expected.IndentString, actual.IndentString);
            Assert.AreEqual(expected.SpacesPerTab, actual.SpacesPerTab);
            Assert.AreEqual(expected.MaxLineWidth, actual.MaxLineWidth);
            Assert.AreEqual(expected.ExpandCommaLists, actual.ExpandCommaLists);
            Assert.AreEqual(expected.TrailingCommas, actual.TrailingCommas);
            Assert.AreEqual(expected.SpaceAfterExpandedComma, actual.SpaceAfterExpandedComma);
            Assert.AreEqual(expected.ExpandBooleanExpressions, actual.ExpandBooleanExpressions);
            Assert.AreEqual(expected.ExpandCaseStatements, actual.ExpandCaseStatements);
            Assert.AreEqual(expected.ExpandBetweenConditions, actual.ExpandBetweenConditions);
            Assert.AreEqual(expected.BreakJoinOnSections, actual.BreakJoinOnSections);
            Assert.AreEqual(expected.UppercaseKeywords, actual.UppercaseKeywords);
            Assert.AreEqual(expected.HTMLColoring, actual.HTMLColoring);
            Assert.AreEqual(expected.KeywordStandardization, actual.KeywordStandardization);
        }
        public void Options_Deserialize_TrailingCommasTrue()
        {
            var options = new TSqlStandardFormatterOptions("TrailingCommas=True");

            Assert.IsTrue(options.TrailingCommas);
        }