Skip to content

Commit

Permalink
Merge pull request #90 from jbogard/net60
Browse files Browse the repository at this point in the history
.NET Standard 2.1 and .NET 6
  • Loading branch information
jbogard authored Jan 10, 2022
2 parents 56c2bfa + 0e49c32 commit 8ac9587
Show file tree
Hide file tree
Showing 17 changed files with 365 additions and 332 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ on:
jobs:
build:
strategy:
matrix:
os: [windows-latest]
fail-fast: false
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup dotnet 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Build and Test
run: ./Build.ps1
shell: pwsh
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ on:
jobs:
build:
strategy:
matrix:
os: [windows-latest]
fail-fast: false
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup dotnet 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Build and Test
run: ./Build.ps1
shell: pwsh
Expand Down
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>10.0</LangVersion>
<NoWarn>$(NoWarn);CS1701;CS1702;CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>
1 change: 0 additions & 1 deletion Respawn.DatabaseTests/MySqlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ public void Dispose()
{
_connection.Close();
_connection.Dispose();
_connection = null;
}
}
}
2 changes: 1 addition & 1 deletion Respawn.DatabaseTests/OracleTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Xunit.Abstractions;

#if NET461 && ORACLE
#if ORACLE
namespace Respawn.DatabaseTests
{
using System;
Expand Down
134 changes: 67 additions & 67 deletions Respawn.DatabaseTests/PostgresTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public async Task InitializeAsync()
dbConnString = "Server=127.0.0.1;Port=5432;User ID=postgres;Password=root;database={0}";
}
var dbName = DateTime.Now.ToString("yyyyMMddHHmmss") + Guid.NewGuid().ToString("N");
using (var connection = new NpgsqlConnection(rootConnString))
await using (var connection = new NpgsqlConnection(rootConnString))
{
connection.Open();

using (var cmd = connection.CreateCommand())
await using (var cmd = connection.CreateCommand())
{
cmd.CommandText = "create database \"" + dbName + "\"";
await cmd.ExecuteNonQueryAsync();
Expand All @@ -55,11 +55,11 @@ public Task DisposeAsync()
[SkipOnCI]
public async Task ShouldDeleteData()
{
_database.Execute("create table \"foo\" (value int)");
await _database.ExecuteAsync("create table \"foo\" (value int)");

for (int i = 0; i < 100; i++)
{
_database.Execute("INSERT INTO \"foo\" VALUES (@0)", i);
await _database.ExecuteAsync("INSERT INTO \"foo\" VALUES (@0)", i);
}

_database.ExecuteScalar<int>("SELECT COUNT(1) FROM \"foo\"").ShouldBe(100);
Expand All @@ -76,13 +76,13 @@ public async Task ShouldDeleteData()
[SkipOnCI]
public async Task ShouldIgnoreTables()
{
_database.Execute("create table foo (Value int)");
_database.Execute("create table bar (Value int)");
await _database.ExecuteAsync("create table foo (Value int)");
await _database.ExecuteAsync("create table bar (Value int)");

for (int i = 0; i < 100; i++)
{
_database.Execute("INSERT INTO \"foo\" VALUES (@0)", i);
_database.Execute("INSERT INTO \"bar\" VALUES (@0)", i);
await _database.ExecuteAsync("INSERT INTO \"foo\" VALUES (@0)", i);
await _database.ExecuteAsync("INSERT INTO \"bar\" VALUES (@0)", i);
}

var checkpoint = new Checkpoint
Expand All @@ -99,13 +99,13 @@ public async Task ShouldIgnoreTables()
[SkipOnCI]
public async Task ShouldIncludeTables()
{
_database.Execute("create table foo (Value int)");
_database.Execute("create table bar (Value int)");
await _database.ExecuteAsync("create table foo (Value int)");
await _database.ExecuteAsync("create table bar (Value int)");

for (int i = 0; i < 100; i++)
{
_database.Execute("INSERT INTO \"foo\" VALUES (@0)", i);
_database.Execute("INSERT INTO \"bar\" VALUES (@0)", i);
await _database.ExecuteAsync("INSERT INTO \"foo\" VALUES (@0)", i);
await _database.ExecuteAsync("INSERT INTO \"bar\" VALUES (@0)", i);
}

var checkpoint = new Checkpoint
Expand All @@ -122,13 +122,13 @@ public async Task ShouldIncludeTables()
[SkipOnCI]
public async Task ShouldHandleRelationships()
{
_database.Execute("create table foo (value int, primary key (value))");
_database.Execute("create table baz (value int, foovalue int, constraint FK_Foo foreign key (foovalue) references foo (value))");
await _database.ExecuteAsync("create table foo (value int, primary key (value))");
await _database.ExecuteAsync("create table baz (value int, foovalue int, constraint FK_Foo foreign key (foovalue) references foo (value))");

for (int i = 0; i < 100; i++)
{
_database.Execute("INSERT INTO \"foo\" VALUES (@0)", i);
_database.Execute("INSERT INTO \"baz\" VALUES (@0, @0)", i);
await _database.ExecuteAsync("INSERT INTO \"foo\" VALUES (@0)", i);
await _database.ExecuteAsync("INSERT INTO \"baz\" VALUES (@0, @0)", i);
}

_database.ExecuteScalar<int>("SELECT COUNT(1) FROM foo").ShouldBe(100);
Expand Down Expand Up @@ -156,19 +156,19 @@ public async Task ShouldHandleRelationships()
[SkipOnCI]
public async Task ShouldHandleCircularRelationships()
{
_database.Execute("create table parent (id int primary key, childid int NULL)");
_database.Execute("create table child (id int primary key, parentid int NULL)");
_database.Execute("alter table parent add constraint FK_Child foreign key (ChildId) references Child (Id)");
_database.Execute("alter table child add constraint FK_Parent foreign key (ParentId) references Parent (Id)");
await _database.ExecuteAsync("create table parent (id int primary key, childid int NULL)");
await _database.ExecuteAsync("create table child (id int primary key, parentid int NULL)");
await _database.ExecuteAsync("alter table parent add constraint FK_Child foreign key (ChildId) references Child (Id)");
await _database.ExecuteAsync("alter table child add constraint FK_Parent foreign key (ParentId) references Parent (Id)");

for (int i = 0; i < 100; i++)
{
_database.Execute("INSERT INTO \"parent\" VALUES (@0, null)", i);
_database.Execute("INSERT INTO \"child\" VALUES (@0, null)", i);
await _database.ExecuteAsync("INSERT INTO \"parent\" VALUES (@0, null)", i);
await _database.ExecuteAsync("INSERT INTO \"child\" VALUES (@0, null)", i);
}

_database.Execute("update parent set childid = 0");
_database.Execute("update child set parentid = 1");
await _database.ExecuteAsync("update parent set childid = 0");
await _database.ExecuteAsync("update child set parentid = 1");

_database.ExecuteScalar<int>("SELECT COUNT(1) FROM parent").ShouldBe(100);
_database.ExecuteScalar<int>("SELECT COUNT(1) FROM child").ShouldBe(100);
Expand All @@ -194,13 +194,13 @@ public async Task ShouldHandleCircularRelationships()
[SkipOnCI]
public async Task ShouldHandleSelfRelationships()
{
_database.Execute("create table foo (id int primary key, parentid int NULL)");
_database.Execute("alter table foo add constraint FK_Parent foreign key (parentid) references foo (id)");
await _database.ExecuteAsync("create table foo (id int primary key, parentid int NULL)");
await _database.ExecuteAsync("alter table foo add constraint FK_Parent foreign key (parentid) references foo (id)");

_database.Execute("INSERT INTO \"foo\" VALUES (@0)", 1);
await _database.ExecuteAsync("INSERT INTO \"foo\" VALUES (@0)", 1);
for (int i = 1; i < 100; i++)
{
_database.Execute("INSERT INTO \"foo\" VALUES (@0, @1)", i+1, i);
await _database.ExecuteAsync("INSERT INTO \"foo\" VALUES (@0, @1)", i+1, i);
}

_database.ExecuteScalar<int>("SELECT COUNT(1) FROM foo").ShouldBe(100);
Expand All @@ -225,29 +225,29 @@ public async Task ShouldHandleSelfRelationships()
[SkipOnCI]
public async Task ShouldHandleComplexCycles()
{
_database.Execute("create table a (id int primary key, b_id int NULL)");
_database.Execute("create table b (id int primary key, a_id int NULL, c_id int NULL, d_id int NULL)");
_database.Execute("create table c (id int primary key, d_id int NULL)");
_database.Execute("create table d (id int primary key)");
_database.Execute("create table e (id int primary key, a_id int NULL)");
_database.Execute("create table f (id int primary key, b_id int NULL)");
_database.Execute("alter table a add constraint FK_a_b foreign key (b_id) references b (id)");
_database.Execute("alter table b add constraint FK_b_a foreign key (a_id) references a (id)");
_database.Execute("alter table b add constraint FK_b_c foreign key (c_id) references c (id)");
_database.Execute("alter table b add constraint FK_b_d foreign key (d_id) references d (id)");
_database.Execute("alter table c add constraint FK_c_d foreign key (d_id) references d (id)");
_database.Execute("alter table e add constraint FK_e_a foreign key (a_id) references a (id)");
_database.Execute("alter table f add constraint FK_f_b foreign key (b_id) references b (id)");


_database.Execute("insert into d (id) values (1)");
_database.Execute("insert into c (id, d_id) values (1, 1)");
_database.Execute("insert into a (id) values (1)");
_database.Execute("insert into b (id, c_id, d_id) values (1, 1, 1)");
_database.Execute("insert into e (id, a_id) values (1, 1)");
_database.Execute("insert into f (id, b_id) values (1, 1)");
_database.Execute("update a set b_id = 1");
_database.Execute("update b set a_id = 1");
await _database.ExecuteAsync("create table a (id int primary key, b_id int NULL)");
await _database.ExecuteAsync("create table b (id int primary key, a_id int NULL, c_id int NULL, d_id int NULL)");
await _database.ExecuteAsync("create table c (id int primary key, d_id int NULL)");
await _database.ExecuteAsync("create table d (id int primary key)");
await _database.ExecuteAsync("create table e (id int primary key, a_id int NULL)");
await _database.ExecuteAsync("create table f (id int primary key, b_id int NULL)");
await _database.ExecuteAsync("alter table a add constraint FK_a_b foreign key (b_id) references b (id)");
await _database.ExecuteAsync("alter table b add constraint FK_b_a foreign key (a_id) references a (id)");
await _database.ExecuteAsync("alter table b add constraint FK_b_c foreign key (c_id) references c (id)");
await _database.ExecuteAsync("alter table b add constraint FK_b_d foreign key (d_id) references d (id)");
await _database.ExecuteAsync("alter table c add constraint FK_c_d foreign key (d_id) references d (id)");
await _database.ExecuteAsync("alter table e add constraint FK_e_a foreign key (a_id) references a (id)");
await _database.ExecuteAsync("alter table f add constraint FK_f_b foreign key (b_id) references b (id)");


await _database.ExecuteAsync("insert into d (id) values (1)");
await _database.ExecuteAsync("insert into c (id, d_id) values (1, 1)");
await _database.ExecuteAsync("insert into a (id) values (1)");
await _database.ExecuteAsync("insert into b (id, c_id, d_id) values (1, 1, 1)");
await _database.ExecuteAsync("insert into e (id, a_id) values (1, 1)");
await _database.ExecuteAsync("insert into f (id, b_id) values (1, 1)");
await _database.ExecuteAsync("update a set b_id = 1");
await _database.ExecuteAsync("update b set a_id = 1");

_database.ExecuteScalar<int>("SELECT COUNT(1) FROM a").ShouldBe(1);
_database.ExecuteScalar<int>("SELECT COUNT(1) FROM b").ShouldBe(1);
Expand Down Expand Up @@ -282,15 +282,15 @@ public async Task ShouldHandleComplexCycles()
[SkipOnCI]
public async Task ShouldExcludeSchemas()
{
_database.Execute("create schema a");
_database.Execute("create schema b");
_database.Execute("create table a.foo (value int)");
_database.Execute("create table b.bar (value int)");
await _database.ExecuteAsync("create schema a");
await _database.ExecuteAsync("create schema b");
await _database.ExecuteAsync("create table a.foo (value int)");
await _database.ExecuteAsync("create table b.bar (value int)");

for (int i = 0; i < 100; i++)
{
_database.Execute("INSERT INTO a.foo VALUES (" + i + ")");
_database.Execute("INSERT INTO b.bar VALUES (" + i + ")");
await _database.ExecuteAsync("INSERT INTO a.foo VALUES (" + i + ")");
await _database.ExecuteAsync("INSERT INTO b.bar VALUES (" + i + ")");
}

var checkpoint = new Checkpoint
Expand All @@ -307,15 +307,15 @@ public async Task ShouldExcludeSchemas()
[SkipOnCI]
public async Task ShouldIncludeSchemas()
{
_database.Execute("create schema a");
_database.Execute("create schema b");
_database.Execute("create table a.foo (value int)");
_database.Execute("create table b.bar (value int)");
await _database.ExecuteAsync("create schema a");
await _database.ExecuteAsync("create schema b");
await _database.ExecuteAsync("create table a.foo (value int)");
await _database.ExecuteAsync("create table b.bar (value int)");

for (int i = 0; i < 100; i++)
{
_database.Execute("INSERT INTO a.foo VALUES (" + i + ")");
_database.Execute("INSERT INTO b.bar VALUES (" + i + ")");
await _database.ExecuteAsync("INSERT INTO a.foo VALUES (" + i + ")");
await _database.ExecuteAsync("INSERT INTO b.bar VALUES (" + i + ")");
}

var checkpoint = new Checkpoint
Expand All @@ -332,10 +332,10 @@ public async Task ShouldIncludeSchemas()
[SkipOnCI]
public async Task ShouldResetSequencesAndIdentities()
{
_database.Execute("CREATE TABLE a (id INT GENERATED ALWAYS AS IDENTITY, value SERIAL)");
_database.Execute("INSERT INTO a DEFAULT VALUES");
_database.Execute("INSERT INTO a DEFAULT VALUES");
_database.Execute("INSERT INTO a DEFAULT VALUES");
await _database.ExecuteAsync("CREATE TABLE a (id INT GENERATED ALWAYS AS IDENTITY, value SERIAL)");
await _database.ExecuteAsync("INSERT INTO a DEFAULT VALUES");
await _database.ExecuteAsync("INSERT INTO a DEFAULT VALUES");
await _database.ExecuteAsync("INSERT INTO a DEFAULT VALUES");

var checkpoint = new Checkpoint
{
Expand Down
24 changes: 9 additions & 15 deletions Respawn.DatabaseTests/Respawn.DatabaseTests.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="IBM.Data.DB2.Core" Version="3.1.0.300" />
<PackageReference Include="MySql.Data" Version="8.0.22" />
<PackageReference Include="Npgsql" Version="5.0.1.1" />
<PackageReference Include="NPoco" Version="4.0.2" />
<PackageReference Include="IBM.Data.DB2.Core" Version="3.1.0.500" />
<PackageReference Include="MySql.Data" Version="8.0.27" />
<PackageReference Include="Npgsql" Version="6.0.2" />
<PackageReference Include="NPoco.SqlServer" Version="5.3.2" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" />
<PackageReference Include="Oracle.ManagedDataAccess" Version="19.10.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" PrivateAssets="All" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0" />
<!--<PackageReference Include="Oracle.ManagedDataAccess" Version="21.5.0" />-->
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Respawn\Respawn.csproj" />
Expand Down
Loading

0 comments on commit 8ac9587

Please sign in to comment.