Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all unit and integration tests. #1194

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
tab_width = 4
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

[*.{csproj,props,build}]
indent_size = 2

[*.{cs,vb}]
# Organize usings
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = true

[*.cs]
# CS1574: XML comment has cref attribute that could not be resolved
dotnet_diagnostic.CS1574.severity = none
69 changes: 69 additions & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build & Run Tests for PR
on:
pull_request:

env:
REPODB_SQLSERVER_CONSTR_MASTER: "Server=tcp:127.0.0.1,41433;Database=master;User ID=sa;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;TrustServerCertificate=True;"
REPODB_SQLSERVER_CONSTR_REPODB: "Server=tcp:127.0.0.1,41433;Database=RepoDb;User ID=sa;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;TrustServerCertificate=True;"
REPODB_SQLSERVER_CONSTR_REPODBTEST: "Server=tcp:127.0.0.1,41433;Database=RepoDbTest;User ID=sa;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;TrustServerCertificate=True;"
REPODB_POSTGRESQL_CONSTR_POSTGRESDB: "Server=127.0.0.1;Port=45432;Database=postgres;User Id=postgres;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"
REPODB_POSTGRESQL_CONSTR: "Server=127.0.0.1;Port=45432;Database=RepoDb;User Id=postgres;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"
REPODB_POSTGRESQL_CONSTR_BULK: "Server=127.0.0.1;Port=45432;Database=RepoDbBulk;User Id=postgres;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"
REPODB_MYSQL_CONSTR_SYS: "Server=127.0.0.1;Port=43306;Database=sys;User ID=root;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"
REPODB_MYSQL_CONSTR_REPODB: "Server=127.0.0.1;Port=43306;Database=RepoDb;User ID=root;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"
REPODB_MYSQL_CONSTR_REPODBTEST: "Server=127.0.0.1;Port=43306;Database=RepoDbTest;User ID=root;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"

jobs:
build:
runs-on: ubuntu-latest

# Services. See docker-compose.yml
services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
ports:
- 127.0.0.1:41433:1433
env:
ACCEPT_EULA: true
MSSQL_SA_PASSWORD: ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2

postgresql:
image: postgres:latest
ports:
- 127.0.0.1:45432:5432
env:
POSTGRES_PASSWORD: ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2

mysql:
image: mysql:latest
ports:
- 127.0.0.1:43306:3306
env:
MYSQL_ROOT_PASSWORD: ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2

steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Setup .NET Versions
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x

- name: build
run: dotnet build -c release

- name: test
run: dotnet test -c release -f net8.0 --no-build -p:TestingPlatformShowTestsFailure=true -p:TestingPlatformCaptureOutput=false

- name: pack packages
run: dotnet pack -c release -p Version="1.14.0-dev-pr-${{ github.run_number }}" -o release RepoDb.Core/RepoDb.All.sln

- name: Package nupkg files
uses: actions/upload-artifact@v3
with:
name: release
path: release/*nupkg
69 changes: 69 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build & Run Tests (Push)
on:
push

env:
REPODB_SQLSERVER_CONSTR_MASTER: "Server=tcp:127.0.0.1,41433;Database=master;User ID=sa;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;TrustServerCertificate=True;"
REPODB_SQLSERVER_CONSTR_REPODB: "Server=tcp:127.0.0.1,41433;Database=RepoDb;User ID=sa;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;TrustServerCertificate=True;"
REPODB_SQLSERVER_CONSTR_REPODBTEST: "Server=tcp:127.0.0.1,41433;Database=RepoDbTest;User ID=sa;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;TrustServerCertificate=True;"
REPODB_POSTGRESQL_CONSTR_POSTGRESDB: "Server=127.0.0.1;Port=45432;Database=postgres;User Id=postgres;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"
REPODB_POSTGRESQL_CONSTR: "Server=127.0.0.1;Port=45432;Database=RepoDb;User Id=postgres;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"
REPODB_POSTGRESQL_CONSTR_BULK: "Server=127.0.0.1;Port=45432;Database=RepoDbBulk;User Id=postgres;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"
REPODB_MYSQL_CONSTR_SYS: "Server=127.0.0.1;Port=43306;Database=sys;User ID=root;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"
REPODB_MYSQL_CONSTR_REPODB: "Server=127.0.0.1;Port=43306;Database=RepoDb;User ID=root;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"
REPODB_MYSQL_CONSTR_REPODBTEST: "Server=127.0.0.1;Port=43306;Database=RepoDbTest;User ID=root;Password=ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2;"

jobs:
build:
runs-on: ubuntu-latest

# Services. See docker-compose.yml
services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
ports:
- 127.0.0.1:41433:1433
env:
ACCEPT_EULA: true
MSSQL_SA_PASSWORD: ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2

postgresql:
image: postgres:latest
ports:
- 127.0.0.1:45432:5432
env:
POSTGRES_PASSWORD: ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2

mysql:
image: mysql:latest
ports:
- 127.0.0.1:43306:3306
env:
MYSQL_ROOT_PASSWORD: ddd53e85-b15e-4da8-91e5-a7d3b00a0ab2

steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Setup .NET Versions
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x

- name: build
run: dotnet build -c release RepoDb.Core/RepoDb.All.sln

- name: test for .Net 8.0
run: dotnet test -c release -f net8.0 --no-build -p:TestingPlatformShowTestsFailure=true -p:TestingPlatformCaptureOutput=false RepoDb.Core/RepoDb.All.sln

- name: pack packages
run: dotnet pack -c release -p Version="1.14.0-dev-${{ github.run_number }}" -o release RepoDb.Core/RepoDb.All.sln

- name: Package nupkg files
uses: actions/upload-artifact@v3
with:
name: release
path: release/*nupkg
21 changes: 18 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Authors>Michael Camara Pendon</Authors>
<Authors>Michael Camara Pendon and others</Authors>
<Company>RepoDb</Company>
<Product>RepoDb</Product>
<Version Condition="'$(Version)' == ''">0.0.1-dev</Version>
<LangVersion>default</LangVersion>
<Copyright>Copyright © 2020</Copyright>
<Copyright>Copyright © 2020-2024</Copyright>
<PackageProjectUrl>https://repodb.net/</PackageProjectUrl>
<RepositoryType>Github</RepositoryType>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<DebugType>portable</DebugType>
<IncludeSymbols>true</IncludeSymbols>
<Nullable>annotations</Nullable>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
</PropertyGroup>
</Project>
<Target Name="SetGenerateBeforeBuild" BeforeTargets="Build">
<!-- IsPackable is set in project files, so delay evaluating this -->
<PropertyGroup>
<GenerateDocumentationFile Condition="'$(IsPackable)' != 'false'">true</GenerateDocumentationFile>
</PropertyGroup>
</Target>
</Project>
43 changes: 43 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<NoWarn>$(NoWarn);NU1507</NoWarn>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Dapper" Version="2.1.35" />
<PackageVersion Include="Dapper.Contrib" Version="2.0.78" />
<PackageVersion Include="linq2db" Version="5.3.2" />
<PackageVersion Include="linq2db.PostgreSQL" Version="5.3.2" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageVersion Include="Microsoft.Data.Sqlite" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
<PackageVersion Include="Microsoft.SqlServer.Types" Version="160.1000.6" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="MSTest" Version="3.6.2" />
<PackageVersion Include="MySql.Data" Version="9.1.0" />
<PackageVersion Include="MySqlConnector" Version="2.3.0" />
<PackageVersion Include="NHibernate" Version="5.5.2" />
<PackageVersion Include="Npgsql" Version="7.0.8" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.0" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageVersion Include="System.Data.Common" Version="4.3.0" />
<PackageVersion Include="System.Data.SQLite.Core" Version="1.0.118" />
<PackageVersion Include="System.Dynamic.Runtime" Version="4.3.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Reflection.Emit" Version="4.7.0" />
<PackageVersion Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
<PackageVersion Include="System.Reflection.TypeExtensions" Version="4.7.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" />
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
<PackageReference Include="Dapper" Version="2.1.21" />
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
<PackageReference Include="linq2db" Version="5.3.2" />
<PackageReference Include="linq2db.PostgreSQL" Version="5.3.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="NHibernate" Version="5.4.6" />
<PackageReference Include="Npgsql" Version="7.0.6" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.0" />
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="Dapper" />
<PackageReference Include="Dapper.Contrib" />
<PackageReference Include="linq2db" />
<PackageReference Include="linq2db.PostgreSQL" />
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="NHibernate" />
<PackageReference Include="Npgsql" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\RepoDb.PostgreSql\RepoDb.PostgreSql\RepoDb.PostgreSql.csproj" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
<PackageReference Include="Dapper" Version="2.1.21" />
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
<PackageReference Include="NHibernate" Version="5.4.6" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="Dapper" />
<PackageReference Include="Dapper.Contrib" />
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
<PackageReference Include="NHibernate" />
<PackageReference Include="System.Linq.Async" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\RepoDb.Extensions\RepoDb.SqlServer.BulkOperations\RepoDb.SqlServer.BulkOperations\RepoDb.SqlServer.BulkOperations.csproj" />
<ProjectReference Include="..\..\RepoDb.PostgreSql\RepoDb.PostgreSql\RepoDb.PostgreSql.csproj" />
<ProjectReference Include="..\..\RepoDb.SqlServer\RepoDb.SqlServer\RepoDb.SqlServer.csproj" />
</ItemGroup>

</Project>
</Project>
4 changes: 0 additions & 4 deletions RepoDb.Core/.editorconfig

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Microsoft.Data.SqlClient;
using System.Linq;
using Microsoft.Data.SqlClient;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RepoDb.IntegrationTests.Models;
using RepoDb.IntegrationTests.Setup;
Expand Down Expand Up @@ -100,6 +100,7 @@ public void TestSqlConnectionInsertForInherited()
public void TestSqlConnectionInsertAllForInherited()
{
// Setup
// warning CA2021: This call will always result in an empty sequence because type 'RepoDb.IntegrationTests.Models.InheritedIdentityTable' is incompatible with type 'RepoDb.IntegrationTests.Models.Entity<RepoDb.IntegrationTests.Models.InheritedIdentityTable>' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2021)
var entities = Helper.CreateInheritedIdentityTables(10)
.OfType<Entity<InheritedIdentityTable>>().ToList();

Expand Down Expand Up @@ -192,6 +193,7 @@ public void TestSqlConnectionMergeForInheritedWithNonEmptyTable()
public void TestSqlConnectionMergeAllForInherited()
{
// Setup
// warning CA2021: This call will always result in an empty sequence because type 'RepoDb.IntegrationTests.Models.InheritedIdentityTable' is incompatible with type 'RepoDb.IntegrationTests.Models.Entity<RepoDb.IntegrationTests.Models.InheritedIdentityTable>' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2021)
var entities = Helper.CreateInheritedIdentityTables(10)
.OfType<Entity<InheritedIdentityTable>>().ToList();

Expand All @@ -217,6 +219,7 @@ public void TestSqlConnectionMergeAllForInherited()
public void TestSqlConnectionMergeAllForInheritedWithNonEmptyTables()
{
// Setup
// warning CA2021: This call will always result in an empty sequence because type 'RepoDb.IntegrationTests.Models.InheritedIdentityTable' is incompatible with type 'RepoDb.IntegrationTests.Models.Entity<RepoDb.IntegrationTests.Models.InheritedIdentityTable>' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2021)
var entities = Helper.CreateInheritedIdentityTables(10)
.OfType<Entity<InheritedIdentityTable>>().ToList();

Expand Down Expand Up @@ -344,6 +347,7 @@ public void TestSqlConnectionUpdateForInheritedViaPrimaryKey()
public void TestSqlConnectionUpdateAllForInherited()
{
// Setup
// warning CA2021: This call will always result in an empty sequence because type 'RepoDb.IntegrationTests.Models.InheritedIdentityTable' is incompatible with type 'RepoDb.IntegrationTests.Models.Entity<RepoDb.IntegrationTests.Models.InheritedIdentityTable>' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2021)
var entities = Helper.CreateInheritedIdentityTables(10)
.OfType<Entity<InheritedIdentityTable>>().ToList();

Expand Down
14 changes: 8 additions & 6 deletions RepoDb.Core/RepoDb.Tests/RepoDb.IntegrationTests/CultureScope.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;

namespace RepoDb.IntegrationTests
{
Expand All @@ -11,16 +9,20 @@ namespace RepoDb.IntegrationTests
/// </summary>
internal sealed class CultureScope : IDisposable
{
private readonly CultureInfo original;
private readonly CultureInfo originalCulture;
private readonly CultureInfo originalUICulture;

public CultureScope(string cultureName)
{
original = CultureInfo.DefaultThreadCurrentCulture;
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.GetCultureInfo(cultureName);
originalCulture = CultureInfo.CurrentCulture;
originalUICulture = CultureInfo.CurrentUICulture;
CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(cultureName);
}

public void Dispose()
{
CultureInfo.DefaultThreadCurrentCulture = original;
CultureInfo.CurrentUICulture = originalUICulture;
CultureInfo.CurrentCulture = originalCulture;
}
}
}
Loading