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

change return type of the PK #294

Merged
merged 3 commits into from
Sep 2, 2024
Merged
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
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
Loading