-
-
Notifications
You must be signed in to change notification settings - Fork 42
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 #294 from paule96/patch-2
change return type of the PK
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 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
46 changes: 46 additions & 0 deletions
46
Tests/DbLocalizationProvider.Storage.PostgreSql.Tests/ResourceRepositoryTests.cs
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,46 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using DbLocalizationProvider.Abstractions; | ||
using Microsoft.Extensions.Options; | ||
using Testcontainers.PostgreSql; | ||
using Xunit; | ||
|
||
namespace DbLocalizationProvider.Storage.PostgreSql.Tests; | ||
|
||
public class ResourceRepositoryTests : IAsyncLifetime | ||
{ | ||
private readonly PostgreSqlContainer _postgreSqlContainer = new PostgreSqlBuilder().Build(); | ||
|
||
public async Task InitializeAsync() | ||
{ | ||
await _postgreSqlContainer.StartAsync(); | ||
Settings.DbContextConnectionString = _postgreSqlContainer.GetConnectionString(); | ||
new SchemaUpdater().Execute(null); | ||
} | ||
|
||
public Task DisposeAsync() | ||
{ | ||
return _postgreSqlContainer.DisposeAsync().AsTask(); | ||
} | ||
|
||
[Fact] | ||
public void CanSaveNewResource() | ||
{ | ||
var ctx = new ConfigurationContext(); | ||
var wrapper = new OptionsWrapper<ConfigurationContext>(ctx); | ||
var repo = new ResourceRepository(wrapper); | ||
var original = new LocalizationResource("testKey", false){ | ||
IsHidden = false, | ||
FromCode = false, | ||
IsModified = true, | ||
Notes = "a test describtion", | ||
Author = "test", | ||
ModificationDate = DateTime.Now | ||
}; | ||
repo.InsertResource(original); | ||
var fromDB = repo.GetByKey(original.ResourceKey); | ||
Assert.Equal(original.Notes, fromDB.Notes); | ||
} | ||
|
||
|
||
} |
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