Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
os: [ ubuntu-latest, windows-latest ]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>0.2.5</Version>
<Version>0.2.6</Version>
</PropertyGroup>
</Project>
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ var generator = new SqlServerTestGenerator(options =>
});
});

List<DatabaseScript> scripts = await generator.Generate();
List<DatabaseTest> scripts = await generator.Generate();
```
The code above will generate a SQLServer `DatabaseScript` list, which will be used by runner to run the tests against database.
The code above will generate a SQLServer `DatabaseTest` list, which will be used by runner to run the tests against database.

Above example adds all three test types to the generator:
- `AddDatabaseObjectExitsRule`: will check if a table `mytable` exists in the database.
Expand All @@ -62,7 +62,7 @@ var runner = new SqlServerTestRunner(scripts, options =>
options.AddSQLServerConnection("server=localhost;user=user;password=mypassword;Initial Catalog=myDatabase");
});

List<DatabaseScriptResult> results = await runner.Run();
List<DatabaseTestResult> results = await runner.Run();
```

Alternatively if you want to use `MySQL` or `PostgreSQL` runners, you can use MySqlTestRunner` or `PostgresqlTestRunner` respectively.
Expand All @@ -71,7 +71,6 @@ Please note that **your user must have correct database permissions**. I suggest

## To-Do

- Implement asserters for processing the `DatabaseScriptResult` list.
- Add more test types if necessary.

## License
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Threading.Tasks;
using Xunit;

namespace QAToolKit.Engine.Database.Test
namespace QAToolKit.Engine.Database.Test.Generators
{
public class MySqlTestGeneratorTests
{
Expand All @@ -17,9 +17,9 @@ public async Task MySqlTableExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "mytable" }, DatabaseObjectType.Table);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"mytable",
$@"SELECT EXISTS(SELECT * FROM `information_schema`.`tables` WHERE `table_name` = 'mytable');",
DatabaseTestType.ObjectExist,
Expand All @@ -38,9 +38,9 @@ public async Task MySqlViewExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "myview" }, DatabaseObjectType.View);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"myview",
$@"SELECT EXISTS(SELECT * FROM `information_schema`.`views` WHERE `table_name` = 'myview');",
DatabaseTestType.ObjectExist,
Expand All @@ -59,9 +59,9 @@ public async Task MySqlStoredProcedureExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "mystoredprocedure" }, DatabaseObjectType.StoredProcedure);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"mystoredprocedure",
$@"SELECT EXISTS(SELECT * FROM `information_schema`.`routines` WHERE `routine_name` = 'mystoredprocedure');",
DatabaseTestType.ObjectExist,
Expand All @@ -80,14 +80,14 @@ public async Task MySqlMultipleTableExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "table1", "table2" }, DatabaseObjectType.Table);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"table1",
$@"SELECT EXISTS(SELECT * FROM `information_schema`.`tables` WHERE `table_name` = 'table1');",
DatabaseTestType.ObjectExist,
DatabaseKind.MySQL),
new DatabaseScript(
new DatabaseTest(
"table2",
$@"SELECT EXISTS(SELECT * FROM `information_schema`.`tables` WHERE `table_name` = 'table2');",
DatabaseTestType.ObjectExist,
Expand All @@ -106,14 +106,14 @@ public async Task MySqlMultipleViewExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "view1", "view2" }, DatabaseObjectType.View);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"view1",
$@"SELECT EXISTS(SELECT * FROM `information_schema`.`views` WHERE `table_name` = 'view1');",
DatabaseTestType.ObjectExist,
DatabaseKind.MySQL),
new DatabaseScript(
new DatabaseTest(
"view2",
$@"SELECT EXISTS(SELECT * FROM `information_schema`.`views` WHERE `table_name` = 'view2');",
DatabaseTestType.ObjectExist,
Expand All @@ -132,14 +132,14 @@ public async Task MySqlMultipleStoredProcedureExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "sp1", "sp2" }, DatabaseObjectType.StoredProcedure);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"sp1",
$@"SELECT EXISTS(SELECT * FROM `information_schema`.`routines` WHERE `routine_name` = 'sp1');",
DatabaseTestType.ObjectExist,
DatabaseKind.MySQL),
new DatabaseScript(
new DatabaseTest(
"sp2",
$@"SELECT EXISTS(SELECT * FROM `information_schema`.`routines` WHERE `routine_name` = 'sp2');",
DatabaseTestType.ObjectExist,
Expand Down Expand Up @@ -179,9 +179,9 @@ public async Task MySqlRecordExistScriptTest_Success()
});
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"mytable",
$@"SELECT EXISTS(SELECT * FROM `mytable` WHERE `name` = 'myname');",
DatabaseTestType.RecordExist,
Expand Down Expand Up @@ -209,9 +209,9 @@ public async Task MySqlRecordCountScriptTest_Success()
});
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"mytable",
$@"SELECT EXISTS (SELECT * FROM `mytable` WHERE (SELECT COUNT(*) AS `count` FROM `mytable`) = 100);",
DatabaseTestType.RecordCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Threading.Tasks;
using Xunit;

namespace QAToolKit.Engine.Database.Test
namespace QAToolKit.Engine.Database.Test.Generators
{
public class PostgresqlTestGeneratorTests
{
Expand All @@ -17,9 +17,9 @@ public async Task PostgresqlTableExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "mytable" }, DatabaseObjectType.Table);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"mytable",
$@"SELECT EXISTS(SELECT * FROM ""information_schema"".""tables"" WHERE ""table_name"" = 'mytable');",
DatabaseTestType.ObjectExist,
Expand All @@ -38,9 +38,9 @@ public async Task PostgresqlViewExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "myview" }, DatabaseObjectType.View);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"myview",
$@"SELECT EXISTS(SELECT * FROM ""information_schema"".""views"" WHERE ""table_name"" = 'myview');",
DatabaseTestType.ObjectExist,
Expand All @@ -59,9 +59,9 @@ public async Task PostgresqlStoredProcedureExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "mystoredprocedure" }, DatabaseObjectType.StoredProcedure);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"mystoredprocedure",
$@"SELECT EXISTS(SELECT * FROM ""information_schema"".""routines"" WHERE ""routine_name"" = 'mystoredprocedure');",
DatabaseTestType.ObjectExist,
Expand All @@ -80,14 +80,14 @@ public async Task PostgresqlMultipleTableExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "table1", "table2" }, DatabaseObjectType.Table);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"table1",
$@"SELECT EXISTS(SELECT * FROM ""information_schema"".""tables"" WHERE ""table_name"" = 'table1');",
DatabaseTestType.ObjectExist,
DatabaseKind.PostgreSQL),
new DatabaseScript(
new DatabaseTest(
"table2",
$@"SELECT EXISTS(SELECT * FROM ""information_schema"".""tables"" WHERE ""table_name"" = 'table2');",
DatabaseTestType.ObjectExist,
Expand All @@ -106,14 +106,14 @@ public async Task PostgresqlMultipleViewExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "view1", "view2" }, DatabaseObjectType.View);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"view1",
$@"SELECT EXISTS(SELECT * FROM ""information_schema"".""views"" WHERE ""table_name"" = 'view1');",
DatabaseTestType.ObjectExist,
DatabaseKind.PostgreSQL),
new DatabaseScript(
new DatabaseTest(
"view2",
$@"SELECT EXISTS(SELECT * FROM ""information_schema"".""views"" WHERE ""table_name"" = 'view2');",
DatabaseTestType.ObjectExist,
Expand All @@ -132,14 +132,14 @@ public async Task PostgresqlMultipleStoredProcedureExistScriptTest_Success()
options.AddDatabaseObjectExitsRule(new string[] { "sp1", "sp2" }, DatabaseObjectType.StoredProcedure);
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"sp1",
$@"SELECT EXISTS(SELECT * FROM ""information_schema"".""routines"" WHERE ""routine_name"" = 'sp1');",
DatabaseTestType.ObjectExist,
DatabaseKind.PostgreSQL),
new DatabaseScript(
new DatabaseTest(
"sp2",
$@"SELECT EXISTS(SELECT * FROM ""information_schema"".""routines"" WHERE ""routine_name"" = 'sp2');",
DatabaseTestType.ObjectExist,
Expand Down Expand Up @@ -179,9 +179,9 @@ public async Task PostgresqlRecordExistScriptTest_Success()
});
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"mytable",
$@"SELECT EXISTS(SELECT * FROM ""mytable"" WHERE ""name"" = 'myname');",
DatabaseTestType.RecordExist,
Expand Down Expand Up @@ -209,9 +209,9 @@ public async Task PostgresqlRecordCountScriptTest_Success()
});
});

var results = new List<DatabaseScript>
var results = new List<DatabaseTest>
{
new DatabaseScript(
new DatabaseTest(
"mytable",
$@"SELECT EXISTS (SELECT * FROM ""mytable"" WHERE (SELECT COUNT(*) AS ""count"" FROM ""mytable"") = 100);",
DatabaseTestType.RecordCount,
Expand Down
Loading