public void TestSelect_MatchCase_MultipleCases()
        {
            SelectBuilder builder = new SelectBuilder();
            AliasedSource source = builder.AddTable(new Table("Table"));
            Column column = source.Column("Column");
            MatchCase options = new MatchCase(column);
            options.AddBranch(new NumericLiteral(0), new StringLiteral("Sunday"));
            options.AddBranch(new NumericLiteral(1), new StringLiteral("Monday"));
            options.AddBranch(new NumericLiteral(2), new StringLiteral("Tuesday"));
            options.AddBranch(new NumericLiteral(3), new StringLiteral("Wednesday"));
            options.AddBranch(new NumericLiteral(4), new StringLiteral("Thursday"));
            options.AddBranch(new NumericLiteral(5), new StringLiteral("Friday"));
            options.AddBranch(new NumericLiteral(6), new StringLiteral("Saturday"));
            builder.AddProjection(options);

            Formatter formatter = new Formatter();
            string actual = formatter.GetCommandText(builder);
            string expected = "SELECT CASE Table.Column WHEN 0 THEN 'Sunday' WHEN 1 THEN 'Monday' WHEN 2 THEN 'Tuesday' WHEN 3 THEN 'Wednesday' WHEN 4 THEN 'Thursday' WHEN 5 THEN 'Friday' WHEN 6 THEN 'Saturday' END FROM Table";
            Assert.AreEqual(expected, actual, "The wrong SQL was generated.");
        }
 private void buildMatch(MatchResult result, MatchCase options)
 {
     MatchResult expressionResult = result.Matches[SqlGrammar.Match.Expression];
     IProjectionItem expression = (IProjectionItem)buildArithmeticItem(expressionResult);
     MatchResult valueResult = result.Matches[SqlGrammar.Match.Value];
     IProjectionItem value = (IProjectionItem)buildArithmeticItem(valueResult);
     options.AddBranch(expression, value);
 }
        public void TestSelect_MatchCase_Else()
        {
            SelectBuilder builder = new SelectBuilder();
            AliasedSource source = builder.AddTable(new Table("Table"));
            Column column = source.Column("Column");
            MatchCase options = new MatchCase(column);
            options.AddBranch(new StringLiteral("Admin"), new StringLiteral("Administrator"));
            options.Default = new StringLiteral("User");
            builder.AddProjection(options);

            Formatter formatter = new Formatter();
            string actual = formatter.GetCommandText(builder);
            string expected = "SELECT CASE Table.Column WHEN 'Admin' THEN 'Administrator' ELSE 'User' END FROM Table";
            Assert.AreEqual(expected, actual, "The wrong SQL was generated.");
        }