Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
hogimn committed Sep 15, 2024
1 parent 478424b commit 4982858
Show file tree
Hide file tree
Showing 35 changed files with 536 additions and 534 deletions.
4 changes: 2 additions & 2 deletions SQL.Formatter.Test/Behavior/BehavesLikeSqlFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ public static void FormatsLonelySemicolon(SqlFormatter.Formatter formatter)

public static void DoesNothingWithEmptyInput(SqlFormatter.Formatter formatter)
{
var result = formatter.Format("");
Assert.Equal("", result);
var result = formatter.Format(string.Empty);
Assert.Equal(string.Empty, result);
}
}
}
16 changes: 8 additions & 8 deletions SQL.Formatter.Test/Db2FormatterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ namespace SQL.Formatter.Test
{
public class Db2FormatterTest
{
public readonly SqlFormatter.Formatter formatter = SqlFormatter.Of(Dialect.Db2);
public readonly SqlFormatter.Formatter Formatter = SqlFormatter.Of(Dialect.Db2);

[Fact]
public void BehavesLikeSqlFormatterTest()
{
BehavesLikeSqlFormatter.Test(formatter);
BehavesLikeSqlFormatter.Test(Formatter);
}

[Fact]
public void CreateTableTest()
{
CreateTable.Test(formatter);
CreateTable.Test(Formatter);
}

[Fact]
public void AlterTableTest()
{
AlterTable.Test(formatter);
AlterTable.Test(Formatter);
}

[Fact]
public void StringsTest()
{
Strings.Test(formatter, new List<string>
Strings.Test(Formatter, new List<string>
{
StringLiteral.DoubleQuote,
StringLiteral.SingleQuote,
Expand All @@ -42,13 +42,13 @@ public void StringsTest()
[Fact]
public void BetweenTest()
{
Between.Test(formatter);
Between.Test(Formatter);
}

[Fact]
public void SchemaTest()
{
Schema.Test(formatter);
Schema.Test(Formatter);
}

[Fact]
Expand All @@ -63,7 +63,7 @@ public void FormatsFetchFirstLikeLimit()
+ " col2 DESC\n"
+ "FETCH FIRST\n"
+ " 20 ROWS ONLY;",
formatter.Format(
Formatter.Format(
"SELECT col1 FROM tbl ORDER BY col2 DESC FETCH FIRST 20 ROWS ONLY;"));
}
}
Expand Down
4 changes: 2 additions & 2 deletions SQL.Formatter.Test/MariaDbFormatterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace SQL.Formatter.Test
{
public class MariaDbFormatterTest
{
public readonly SqlFormatter.Formatter formatter = SqlFormatter.Of(Dialect.MariaDb);
public readonly SqlFormatter.Formatter Formatter = SqlFormatter.Of(Dialect.MariaDb);

[Fact]
public void BehavesLikeMariaDbFormatterTest()
{
BehavesLikeMariaDbFormatter.Test(formatter);
BehavesLikeMariaDbFormatter.Test(Formatter);
}
}
}
6 changes: 3 additions & 3 deletions SQL.Formatter.Test/MySqlFormatterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ namespace SQL.Formatter.Test
{
public class MySqlFormatterTest
{
public readonly SqlFormatter.Formatter formatter = SqlFormatter.Of(Dialect.MySql);
public readonly SqlFormatter.Formatter Formatter = SqlFormatter.Of(Dialect.MySql);

[Fact]
public void BehavesLikeMariaDbFormatterTest()
{
BehavesLikeMariaDbFormatter.Test(formatter);
BehavesLikeMariaDbFormatter.Test(Formatter);
}

[Fact]
public void AdditionalMySqlOperator()
{
Operators.Test(formatter, new List<string>
Operators.Test(Formatter, new List<string>
{
"->",
"->>"
Expand Down
36 changes: 18 additions & 18 deletions SQL.Formatter.Test/N1qlFormatterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ namespace SQL.Formatter.Test
{
public class N1qlFormatterTest
{
public readonly SqlFormatter.Formatter formatter = SqlFormatter.Of(Dialect.N1ql);
public readonly SqlFormatter.Formatter Formatter = SqlFormatter.Of(Dialect.N1ql);

[Fact]
public void BehavesLikeSqlFormatterTest()
{
BehavesLikeSqlFormatter.Test(formatter);
BehavesLikeSqlFormatter.Test(Formatter);
}

[Fact]
public void StringsTest()
{
Strings.Test(formatter, new List<string>
Strings.Test(Formatter, new List<string>
{
StringLiteral.DoubleQuote,
StringLiteral.SingleQuote,
Expand All @@ -30,19 +30,19 @@ public void StringsTest()
[Fact]
public void BetweenTest()
{
Between.Test(formatter);
Between.Test(Formatter);
}

[Fact]
public void SchemaTest()
{
Schema.Test(formatter);
Schema.Test(Formatter);
}

[Fact]
public void OperatorsTest()
{
Operators.Test(formatter, new List<string>
Operators.Test(Formatter, new List<string>
{
"%",
"==",
Expand All @@ -53,7 +53,7 @@ public void OperatorsTest()
[Fact]
public void JoinTest()
{
Join.Test(formatter, new List<string>
Join.Test(Formatter, new List<string>
{
"FULL", "CROSS", "NATURAL"
});
Expand All @@ -67,7 +67,7 @@ public void ReplacesDollarNumberedPlaceholdersWithParamValues()
+ " second,\n"
+ " third,\n"
+ " first;",
formatter.Format(
Formatter.Format(
"SELECT $1, $2, $0;",
new Dictionary<string, string>
{
Expand All @@ -86,7 +86,7 @@ public void ReplacesDollarVariablesWithParamValues()
+ @" 'var value'," + "\n"
+ @" 'var value'," + "\n"
+ @" 'var value';",
formatter.Format(
Formatter.Format(
@"SELECT $variable, $'var name', $""var name"", $`var name`;",
new Dictionary<string, string>
{
Expand All @@ -104,7 +104,7 @@ public void RecognizesDollarVariables()
+ @" $'var name'," + "\n"
+ @" $""var name""," + "\n"
+ @" $`var name`;",
formatter.Format(
Formatter.Format(
@"SELECT $variable, $'var name', $""var name"", $`var name`;"));
}

Expand All @@ -118,7 +118,7 @@ public void FormatsUpdateQueryWithUseKeysAndReturning()
+ " 'baldwin'\n"
+ "SET\n"
+ " type = 'actor' RETURNING tutorial.type",
formatter.Format(
Formatter.Format(
"UPDATE tutorial USE KEYS 'baldwin' SET type = 'actor' RETURNING tutorial.type"));
}

Expand All @@ -130,7 +130,7 @@ public void FormatsExplainedDeleteQueryWithUseKeysAndReturning()
+ " tutorial t\n"
+ "USE KEYS\n"
+ " 'baldwin' RETURNING t",
formatter.Format(
Formatter.Format(
"EXPLAIN DELETE FROM tutorial t USE KEYS 'baldwin' RETURNING t"));
}

Expand All @@ -146,7 +146,7 @@ public void FormatsSelectQueryWithNestAndUseKeys()
+ " 'Elinor_33313792'\n"
+ "NEST\n"
+ " orders_with_users orders ON KEYS ARRAY s.order_id FOR s IN usr.shipped_order_history END;",
formatter.Format(
Formatter.Format(
"SELECT * FROM usr\n"
+ "USE KEYS 'Elinor_33313792' NEST orders_with_users orders\n"
+ "ON KEYS ARRAY s.order_id FOR s IN usr.shipped_order_history END;"));
Expand All @@ -162,7 +162,7 @@ public void FormatsSelectQueryWithUnnestTopLevelReservedWord()
+ " tutorial\n"
+ "UNNEST\n"
+ " tutorial.children c;",
formatter.Format(
Formatter.Format(
"SELECT * FROM tutorial UNNEST tutorial.children c;"));
}

Expand All @@ -188,7 +188,7 @@ public void FormatsInsertWithLargeObjectAndArrayLiterals()
+ " 'hello': 'world'\n"
+ " }\n"
+ " );",
formatter.Format(
Formatter.Format(
"INSERT INTO heroes (KEY, VALUE) VALUES ('123', {'id': 1, 'type': 'Tarzan',\n"
+ "'array': [123456789, 123456789, 123456789, 123456789, 123456789], 'hello': 'world'});"));
}
Expand All @@ -201,7 +201,7 @@ public void FormatsInsertWithCurlyBracketObjectLiteral()
+ " heroes (KEY, VALUE)\n"
+ "VALUES\n"
+ " ('123', {'id': 1, 'type': 'Tarzan'});",
formatter.Format(
Formatter.Format(
"INSERT INTO heroes (KEY, VALUE) VALUES ('123', {'id':1,'type':'Tarzan'});"));
}

Expand All @@ -215,7 +215,7 @@ public void FormatsSelectQueryWithPrimaryKeyQuerying()
+ " tutorial\n"
+ "USE KEYS\n"
+ " ['dave', 'ian'];",
formatter.Format(
Formatter.Format(
"SELECT fname, email FROM tutorial USE KEYS ['dave', 'ian'];"));
}

Expand All @@ -227,7 +227,7 @@ public void FormatsSelectQueryWithElementSelectionExpression()
+ " order_lines[0].productId\n"
+ "FROM\n"
+ " orders;",
formatter.Format(
Formatter.Format(
"SELECT order_lines[0].productId FROM orders;"));
}
}
Expand Down
Loading

0 comments on commit 4982858

Please sign in to comment.