Skip to content

Commit

Permalink
Merge pull request #294 from paule96/patch-2
Browse files Browse the repository at this point in the history
change return type of the PK
  • Loading branch information
valdisiljuconoks authored Sep 2, 2024
2 parents 05338ad + 427b16f commit fecefa8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Testcontainers.PostgreSql" Version="3.9.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -21,7 +22,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\DbLocalizationProvider.Storage.PostgreSql\DbLocalizationProvider.Storage.PostgreSql.csproj" />
<ProjectReference Include="..\..\src\DbLocalizationProvider.Storage.PostgreSQL\DbLocalizationProvider.Storage.PostgreSql.csproj" />
</ItemGroup>

</Project>
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);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public void InsertResource(LocalizationResource resource)
cmd.Parameters.AddSafeWithValue("notes", resource.Notes);

// get inserted resource ID
var resourcePk = (int)cmd.ExecuteScalar();
var resourcePk = (long)cmd.ExecuteScalar();

// if there are also provided translations - execute those in the same connection also
if (resource.Translations.Any())
Expand Down

0 comments on commit fecefa8

Please sign in to comment.