## Summary
All data folders are now migrated to JSON in the `{mandator}/{year}` layout, so the one-time migration from #2 is no longer needed.
- Remove `DataMigrator` and its 15 tests, its DI registration and the startup call in `Program.cs` (`Main` is back to a plain `app.Run()`).
- Remove the old-layout year-folder filter in `SettingsService.GetMandators` and the `DataFolders.IsYear` helper it used.
- Remove the migration notes from `CLAUDE.md` and code comments.
- Rename `.xml` paths to `.json` in a repository-cache test (cosmetic).
Bank-statement import (CAMT053 `.xml` in `StatementImport`) is unaffected.
**Note:** this version expects every data folder to be migrated already. An old-layout or XML data folder is no longer converted. The original XMLs remain in `backup/{mandator}/{year}/xml-<timestamp>/` and can be deleted manually.
## Test plan
- [x] `dotnet build --no-incremental`: no warnings
- [x] `dotnet test`: 62/62 pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reviewed-on: #3
Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
Co-committed-by: Claudio Schaad <c.schaad@pog.ch>
58 lines
1.9 KiB
C#
58 lines
1.9 KiB
C#
using Schaad.Accounting.Repositories;
|
|
using Shouldly;
|
|
|
|
namespace Schaad.Accounting.Tests;
|
|
|
|
public class RepositoryCacheTestShould
|
|
{
|
|
[Fact]
|
|
public async Task CallLoaderOnceWhenKeyIsRequestedRepeatedly()
|
|
{
|
|
var cache = new RepositoryCache();
|
|
var loaderCalls = 0;
|
|
|
|
var first = await cache.GetOrLoadAsync("key", () => { loaderCalls++; return Task.FromResult(new List<int> { 1, 2 }); });
|
|
var second = await cache.GetOrLoadAsync("key", () => { loaderCalls++; return Task.FromResult(new List<int> { 99 }); });
|
|
|
|
loaderCalls.ShouldBe(1);
|
|
second.ShouldBeSameAs(first);
|
|
second.ShouldBe(new[] { 1, 2 });
|
|
}
|
|
|
|
[Fact]
|
|
public async Task KeepEntriesSeparateWhenKeysDiffer()
|
|
{
|
|
var cache = new RepositoryCache();
|
|
|
|
var a = await cache.GetOrLoadAsync("a", () => Task.FromResult(new List<int> { 1 }));
|
|
var b = await cache.GetOrLoadAsync("b", () => Task.FromResult(new List<int> { 2 }));
|
|
|
|
b.ShouldNotBeSameAs(a);
|
|
a.ShouldBe(new[] { 1 });
|
|
b.ShouldBe(new[] { 2 });
|
|
}
|
|
|
|
[Fact]
|
|
public async Task ReloadFromLoaderWhenKeyIsInvalidated()
|
|
{
|
|
var cache = new RepositoryCache();
|
|
var loaderCalls = 0;
|
|
|
|
await cache.GetOrLoadAsync("k", () => { loaderCalls++; return Task.FromResult(new List<int> { 1 }); });
|
|
cache.Invalidate("k");
|
|
await cache.GetOrLoadAsync("k", () => { loaderCalls++; return Task.FromResult(new List<int> { 2 }); });
|
|
|
|
loaderCalls.ShouldBe(2);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task MatchKeysCaseInsensitivelyWhenLookingUp()
|
|
{
|
|
var cache = new RepositoryCache();
|
|
|
|
await cache.GetOrLoadAsync("Path/To/File.json", () => Task.FromResult(new List<int> { 1 }));
|
|
var upper = await cache.GetOrLoadAsync("PATH/TO/FILE.JSON", () => Task.FromResult(new List<int> { 99 }));
|
|
|
|
upper.ShouldBe(new[] { 1 });
|
|
}
|
|
}
|