In the Unit Test i try to access the resources. this works fine in Visual Studio, ReSharper and via dotnet test.
But not in NCrunch, if i look in the temp folder of NCrunch then the satellite resource assemblies are missing.
public class ResourceTests
{
readonly ServiceProvider _provider;
public ResourceTests()
{
// Only to avoid complicated mocking
var services = new ServiceCollection();
services.AddOptions();
services.AddLogging();
_provider = services.BuildServiceProvider();
}
/// this works in ncrunch
[Fact]
public void LocalResources_should_be_resolver()
{
var factory = ActivatorUtilities.CreateInstance<ResourceManagerStringLocalizerFactory>(_provider);
var localizerEn = factory.Create(typeof(LocalResource));
var localizerDe = factory.Create(typeof(LocalResource)).WithCulture(new CultureInfo("de-DE"));
Assert.NotEmpty(localizerEn.GetAllStrings());
Assert.NotEmpty(localizerDe.GetAllStrings());
}
/// this does not works in ncrunch - but works in VS, with dotnet test and with ReSharper
[Fact]
public void ExternalResources_should_be_resolved()
{
var factory = ActivatorUtilities.CreateInstance<ResourceManagerStringLocalizerFactory>(_provider);
var localizerEn = factory.Create(typeof(ExternalResource));
var localizerDe = factory.Create(typeof(ExternalResource)).WithCulture(new CultureInfo("de-DE"));
Assert.NotEmpty(localizerEn.GetAllStrings());
Assert.NotEmpty(localizerDe.GetAllStrings());
}
}
Result of dotnet test
λ dotnet test
Build started, please wait...
Build completed.
Test run for C:\dev\private\NCrunchNETCoreLocalizationTests\NCrunchNETCoreLocalizationTests\bin\Debug\netcoreapp2.1\NCrunchNETCoreLocalizationTests.dll(.NETCoreApp,Version=v2.1)
Microsoft (R) Test Execution Command Line Tool Version 15.9.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Total tests: 2. Passed: 2. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 1,8353 Seconds
C:\dev\private\NCrunchNETCoreLocalizationTests\NCrunchNETCoreLocalizationTests
Here is the Sample solution
https://1drv.ms/u/s!AmXNl8dqs5HUpMpSHg7qHwCfZsciyQ