Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pomianowski committed May 19, 2024
1 parent 2af1ed2 commit 1908354
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 68 deletions.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
<PackageVersion Include="System.Text.Json" Version="6.0.0" />
<PackageVersion Include="PolySharp" Version="1.13.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.4" />
<PackageVersion Include="xunit" Version="2.6.2" />
Expand Down
14 changes: 4 additions & 10 deletions Lepo.i18n.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ThirdPartyNotices.txt = ThirdPartyNotices.txt
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lepo.i18n.Yaml", "src\Lepo.i18n.Yaml\Lepo.i18n.Yaml.csproj", "{B935AF12-97DD-419E-99C3-8F76D9A0229D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lepo.i18n.Json", "src\Lepo.i18n.Json\Lepo.i18n.Json.csproj", "{83E6E4CA-DC57-4F68-8FDF-A78BE95BFEA5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lepo.i18n.Json", "src\Lepo.i18n.Json\Lepo.i18n.Json.csproj", "{83E6E4CA-DC57-4F68-8FDF-A78BE95BFEA5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{AA93DD64-B88F-46ED-9981-EABA0F3C3E95}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lepo.i18n.UnitTests", "tests\Lepo.i18n.UnitTests\Lepo.i18n.UnitTests.csproj", "{98789E33-F370-46FF-B4B6-CEAA81E9C2C3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lepo.i18n.UnitTests", "tests\Lepo.i18n.UnitTests\Lepo.i18n.UnitTests.csproj", "{98789E33-F370-46FF-B4B6-CEAA81E9C2C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lepo.i18n.DependencyInjection", "src\Lepo.i18n.DependencyInjection\Lepo.i18n.DependencyInjection.csproj", "{6297D5AB-EE2C-4DBB-BE29-B4813BB8803F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lepo.i18n.DependencyInjection", "src\Lepo.i18n.DependencyInjection\Lepo.i18n.DependencyInjection.csproj", "{6297D5AB-EE2C-4DBB-BE29-B4813BB8803F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lepo.i18n.DependencyInjection.UnitTests", "tests\Lepo.i18n.DependencyInjection.UnitTests\Lepo.i18n.DependencyInjection.UnitTests.csproj", "{274021AA-F5A4-4A02-B8B7-224B254031A1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lepo.i18n.DependencyInjection.UnitTests", "tests\Lepo.i18n.DependencyInjection.UnitTests\Lepo.i18n.DependencyInjection.UnitTests.csproj", "{274021AA-F5A4-4A02-B8B7-224B254031A1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -44,10 +42,6 @@ Global
{94DA5B37-AD49-42C0-AB0C-86055FE111B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94DA5B37-AD49-42C0-AB0C-86055FE111B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94DA5B37-AD49-42C0-AB0C-86055FE111B9}.Release|Any CPU.Build.0 = Release|Any CPU
{B935AF12-97DD-419E-99C3-8F76D9A0229D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B935AF12-97DD-419E-99C3-8F76D9A0229D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B935AF12-97DD-419E-99C3-8F76D9A0229D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B935AF12-97DD-419E-99C3-8F76D9A0229D}.Release|Any CPU.Build.0 = Release|Any CPU
{83E6E4CA-DC57-4F68-8FDF-A78BE95BFEA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83E6E4CA-DC57-4F68-8FDF-A78BE95BFEA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83E6E4CA-DC57-4F68-8FDF-A78BE95BFEA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
1 change: 1 addition & 0 deletions src/Lepo.i18n.DependencyInjection/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
global using Microsoft.Extensions.Localization;
global using System;
global using System.Collections.Generic;
global using System.Globalization;
global using System.Linq;
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
System.Runtime.CompilerServices.SkipLocalsInitAttribute;
</PolySharpIncludeGeneratedTypes>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Lepo.i18n\Lepo.i18n.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Action<LocalizationBuilder> configure

configure(builder);

LocalizationProvider localizer = new(builder.GetLocalizations());
LocalizationProvider localizer = new(CultureInfo.CurrentCulture, builder.GetLocalizations());
LocalizationProvider.SetInstance(localizer);

_ = services.AddSingleton<ILocalizationProvider>(
Expand Down
4 changes: 4 additions & 0 deletions src/Lepo.i18n.Json/Lepo.i18n.Json.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
</PolySharpIncludeGeneratedTypes>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Lepo.i18n\Lepo.i18n.csproj" />
</ItemGroup>
Expand Down
6 changes: 2 additions & 4 deletions src/Lepo.i18n.Wpf/ApplicationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
// Copyright (C) Leszek Pomianowski and Lepo.i18n Contributors.
// All Rights Reserved.

using System.Windows;

namespace Lepo.i18n.Wpf;

public static class ApplicationExtensions
{
public static Application AddStringLocalizer(
public static Application UseStringLocalizer(
this Application app,
Action<LocalizationBuilder> configure
)
Expand All @@ -18,7 +16,7 @@ Action<LocalizationBuilder> configure

configure(builder);

LocalizationProvider localizer = new(builder.GetLocalizations());
LocalizationProvider localizer = new(CultureInfo.CurrentUICulture, builder.GetLocalizations());
LocalizationProvider.SetInstance(localizer);

return app;
Expand Down
4 changes: 4 additions & 0 deletions src/Lepo.i18n.Wpf/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
// All Rights Reserved.

global using System;
global using System.Globalization;
global using System.Runtime.InteropServices;
global using System.Windows;
global using System.Windows.Markup;
11 changes: 11 additions & 0 deletions src/Lepo.i18n.Wpf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and Lepo.i18n Contributors.
// All Rights Reserved.

[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

[assembly: XmlnsPrefix("http://schemas.lepo.co/i18n/2022/xaml", "i18n")]
[assembly: XmlnsDefinition("http://schemas.lepo.co/i18n/2022/xaml", "Lepo.i18n")]
[assembly: XmlnsDefinition("http://schemas.lepo.co/i18n/2022/xaml", "Lepo.i18n.Wpf")]
2 changes: 0 additions & 2 deletions src/Lepo.i18n.Wpf/StringLocalizerExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Copyright (C) Leszek Pomianowski and Lepo.i18n Contributors.
// All Rights Reserved.

using System.Windows.Markup;

namespace Lepo.i18n.Wpf;

/// <summary>
Expand Down
9 changes: 0 additions & 9 deletions src/Lepo.i18n.Yaml/GlobalUsings.cs

This file was deleted.

38 changes: 0 additions & 38 deletions src/Lepo.i18n.Yaml/Lepo.i18n.Yaml.csproj

This file was deleted.

4 changes: 1 addition & 3 deletions src/Lepo.i18n/LocalizationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@

namespace Lepo.i18n;

public class LocalizationProvider(IEnumerable<LocalizationSet> sets) : ILocalizationProvider
public class LocalizationProvider(CultureInfo culture, IEnumerable<LocalizationSet> sets) : ILocalizationProvider
{
private static LocalizationProvider? instance;

private static CultureInfo culture = CultureInfo.CurrentCulture;

public LocalizationSet? Get(CultureInfo culture)
{
return sets.FirstOrDefault(s => s.Culture.Equals(culture));
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void FromResource_ShouldReturnWithoutTranslation_WhenResourceIsEmpty()

_ = services.AddStringLocalizer(b =>
{
_ = b.FromResource(assembly, "Lepo.i18n.UnitTests.Resources.Test", new("cs-CZ"));
_ = b.FromResource(assembly, "Lepo.i18n.DependencyInjection.UnitTests.Resources.Test", new("cs-CZ"));
});

ServiceProvider serviceProvider = services.BuildServiceProvider();
Expand Down

0 comments on commit 1908354

Please sign in to comment.