-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from salesHgabriel/feature/create-integration-t…
…ests Feature/create integration tests
- Loading branch information
Showing
17 changed files
with
489 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
|
||
} |
Oops, something went wrong.