Skip to content

Commit

Permalink
Merge pull request #2 from salesHgabriel/feature/create-integration-t…
Browse files Browse the repository at this point in the history
…ests

Feature/create integration tests
  • Loading branch information
salesHgabriel authored Dec 21, 2024
2 parents f88d048 + 53a596f commit 0d269f3
Show file tree
Hide file tree
Showing 17 changed files with 489 additions and 212 deletions.
15 changes: 9 additions & 6 deletions build_and_test.yaml → .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Build and Tests
on: pull_request

jobs:
build_teste_nuget_package:
name: Build and Teste SSync Client and Server
build_tests_nuget_package:
name: Build and Tests SSync Client and Server
runs-on: ubuntu-latest
steps:

Expand All @@ -24,8 +24,8 @@ jobs:
run: dotnet build --no-restore ./src/SSync.Client.LitebDB/SSync.Client.LitebDB.csproj


- name: Test Client
run: dotnet test --no-build --verbosity normal ./src/SSync.Client.LitebDB/SSync.Client.LitebDB.csproj
- name: Run Unit Tests Client
run: dotnet test --no-build --verbosity normal ./test/SSync.Client.LiteDB.Tests/SSync.Client.LiteDB.Tests.csproj


# end project ssync client
Expand All @@ -40,7 +40,10 @@ jobs:
- name: Build Server
run: dotnet build --no-restore ./src/SSync.Server.LitebDB/SSync.Server.LitebDB.csproj

- name: Test Server
run: dotnet test --no-build --verbosity normal ./src/SSync.Server.LitebDB/SSync.Server.LitebDB.csproj
- name: Run Unit Tests Server
run: dotnet test --no-build --verbosity normal ./test/SSync.Server.LitebDB.Tests/SSync.Server.LitebDB.Tests.csproj

- name: Run Integration Tests Server
run: dotnet test --no-build --verbosity normal ./test/SSync.Server.LitebDB.Integration.Tests/SSync.Server.LitebDB.Integration.Tests.csproj

# end project ssync server
2 changes: 0 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
- name: Build Client
run: dotnet build --no-restore ./src/SSync.Client.LitebDB/SSync.Client.LitebDB.csproj


- name: Test Client
run: dotnet test --no-build --verbosity normal ./src/SSync.Client.LitebDB/SSync.Client.LitebDB.csproj

Expand Down Expand Up @@ -64,7 +63,6 @@ jobs:
run: |
dotnet pack ./src/SSync.Server.LitebDB/SSync.Server.LitebDB.csproj -c Release -o output-server
- name: Publish Server to Nuget.Org
run: |
dotnet nuget push output-server/*.nupkg -k ${{ secrets.NUGET_API_KEY_SERVER }} -s https://api.nuget.org/v3/index.json --skip-duplicate
Expand Down
9 changes: 8 additions & 1 deletion SSync.LiteDB.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SSync.Server.LitebDB.Tests"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{36F96630-08DF-4386-AADB-C8E121988D5B}"
ProjectSection(SolutionItems) = preProject
build_and_test.yaml = build_and_test.yaml
.github\workflows\publish.yaml = .github\workflows\publish.yaml
readme-ptBR.md = readme-ptBR.md
readme.md = readme.md
.github\workflows\build_and_test.yaml = .github\workflows\build_and_test.yaml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SSync.Server.LitebDB.Integration.Tests", "test\SSync.Server.LitebDB.Integration.Tests\SSync.Server.LitebDB.Integration.Tests.csproj", "{1DF82900-C83A-4813-969C-EFB4E50E4476}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -57,6 +59,10 @@ Global
{41717DBF-139C-4A74-8BA4-E9B2B289F529}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41717DBF-139C-4A74-8BA4-E9B2B289F529}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41717DBF-139C-4A74-8BA4-E9B2B289F529}.Release|Any CPU.Build.0 = Release|Any CPU
{1DF82900-C83A-4813-969C-EFB4E50E4476}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DF82900-C83A-4813-969C-EFB4E50E4476}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DF82900-C83A-4813-969C-EFB4E50E4476}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DF82900-C83A-4813-969C-EFB4E50E4476}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -68,6 +74,7 @@ Global
{3B922C05-29AC-46F4-AB13-7D68418DA126} = {EFFD198B-C248-4AE0-9085-2EDFAEA57294}
{47F5CD68-81DD-453D-A5A3-F42FDB844775} = {5F8FC591-4435-4387-838B-D8EC7768C42D}
{41717DBF-139C-4A74-8BA4-E9B2B289F529} = {5F8FC591-4435-4387-838B-D8EC7768C42D}
{1DF82900-C83A-4813-969C-EFB4E50E4476} = {5F8FC591-4435-4387-838B-D8EC7768C42D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F1AE824B-4065-4342-A7CD-35122F2B99B4}
Expand Down
57 changes: 57 additions & 0 deletions src/SSync.Server.LiteDB.PlayGround/Data/TestDbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SSync.Server.LitebDB.Abstractions;
using SSync.Server.LiteDB.PlayGround.Model;

namespace SSync.Server.LiteDB.PlayGround.Data;

public class TestDbContext : DbContext, ISSyncDbContextTransaction
{
private IDbContextTransaction? transaction;
private readonly IConfiguration _configuration;


public TestDbContext(DbContextOptions<TestDbContext> options, IConfiguration configuration)
: base(options)
{
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);

_configuration = configuration;
}

public DbSet<User> User => Set<User>();
public DbSet<Finance> Finances => Set<Finance>();

public async Task BeginTransactionSyncAsync()
=> transaction = await Database.BeginTransactionAsync();

public async Task CommitSyncAsync()
=> await Database.CommitTransactionAsync();

public Task CommitTransactionSyncAsync()
{
ArgumentNullException.ThrowIfNull(transaction);

return transaction.CommitAsync();
}

public Task RollbackTransactionSyncAsync()
{
ArgumentNullException.ThrowIfNull(transaction);
return transaction.RollbackAsync();
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<User>()
.Property(u => u.Id).HasConversion(new GuidToStringConverter());

modelBuilder.Entity<Finance>()
.Property(u => u.Id).HasConversion(new GuidToStringConverter());

base.OnModelCreating(modelBuilder);
}

}
10 changes: 10 additions & 0 deletions src/SSync.Server.LiteDB.PlayGround/Model/Finance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using SSync.Server.LitebDB.Abstractions;

namespace SSync.Server.LiteDB.PlayGround.Model;

public class Finance : ISSyncEntityRoot
{
public double Price { get; set; }


}
9 changes: 9 additions & 0 deletions src/SSync.Server.LiteDB.PlayGround/Model/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using SSync.Server.LitebDB.Abstractions;

namespace SSync.Server.LiteDB.PlayGround.Model;

public class User : ISSyncEntityRoot
{
public string? Name { get; set; }

}
Loading

0 comments on commit 0d269f3

Please sign in to comment.