Skip to content

Commit

Permalink
Add unit testing too
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Oct 29, 2021
1 parent 672e2a9 commit 29e122b
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ public class QuerySqlGeneratorTest
[InlineData("")]
[InlineData("--SELECT")]
public void CheckComposableSql_throws(string sql)
=> Assert.Equal(
{
Assert.Equal(
RelationalStrings.FromSqlNonComposable,
Assert.Throws<InvalidOperationException>(
() => CreateDummyQuerySqlGenerator().CheckComposableSql(sql)).Message);

Assert.Equal(
RelationalStrings.FromSqlNonComposable,
Assert.Throws<InvalidOperationException>(
() => CreateDummyQuerySqlGenerator().CheckComposableSql(sql.Replace("SELECT", "WITH"))).Message);
}

[Theory]
[InlineData("SELECT something")]
[InlineData(" SELECT something")]
Expand All @@ -36,7 +43,11 @@ public void CheckComposableSql_throws(string sql)
[InlineData(" /* multi\n*line\r\n * comment */ \nSELECT--\n1")]
[InlineData("SELECT/* comment */1")]
public void CheckComposableSql_does_not_throw(string sql)
=> CreateDummyQuerySqlGenerator().CheckComposableSql(sql);
{
CreateDummyQuerySqlGenerator().CheckComposableSql(sql);

CreateDummyQuerySqlGenerator().CheckComposableSql(sql.Replace("SELECT", "WITH"));
}

private DummyQuerySqlGenerator CreateDummyQuerySqlGenerator()
=> new(
Expand Down

0 comments on commit 29e122b

Please sign in to comment.