e4d8476782
Snapshot of the parallel batch (Phases 2 + 3 + 5) at session pause. Solution does
NOT build cleanly yet — known cross-phase compile issues remain to be resolved
before review. See plans/initial-implementation/PLAN.md "Resume Notes" section
for the exact tomorrow-morning action list.
Phase 2 (Storage):
- Repository interfaces in Marathon.Application/Abstractions
- DateRange, ExportKind, StorageOptions in Marathon.Application/Storage
- EF Core 8 + SQLite (WAL) persistence: 7 entities + configurations + 4 repos
- Hand-written InitialCreate migration (dotnet ef blocked by parallel work)
- ClosedXML ExcelExporter with exact customer-spec wide columns
- PersistenceModule.AddMarathonPersistence DI extension
- Round-trip + export tests (cannot run yet — see cross-phase issues)
Phase 3 (Scraping):
- IOddsScraper, IBetPlacer in Marathon.Application/Abstractions
- ScrapingOptions in Marathon.Infrastructure/Configuration
- MarathonbetScraper with 4 parsers (Upcoming, Live, EventOdds, Results)
- Helpers: ServerTimeProvider, PeriodScopeMapper, OutcomeCodeMapper, MoscowDateParser
- UserAgentRotatorHandler + Polly v8 resilience pipeline
- ScrapingModule.AddMarathonScraping DI extension
- GlobalUsings.cs aliases for EventId / Configuration disambiguation
- Parser tests with trimmed HTML fixtures
- ScrapeResultsAsync interim no-op (Phase 8 will replace via watch-list polling)
Phase 5 (UI shell — killed mid-final-verify, assumed ~95%):
- Marathon.UI populated: MainLayout, App.razor, Pages (Home, Settings),
Components, Theme (MarathonTheme.cs + Tokens.cs + app.css), Resources
(SharedResource.{cs,ru.resx,en.resx}), Services (ISettingsWriter), wwwroot
- WPF host: App.xaml(.cs), MainWindow.xaml(.cs), Marathon.Hosts.WpfBlazor.csproj
with Microsoft.AspNetCore.Components.WebView.Wpf + MudBlazor + Serilog
- appsettings.json + appsettings.Development.json with all sections wired
- bUnit tests: MainLayoutTests, LocaleSwitcherTests, ThemeToggleTests,
JsonSettingsWriterTests + Support helpers
Cross-phase issues to resolve at next session:
1. Phase 2 repository classes are 'internal' — Phase 3's tests can't reference
them. Fix: add InternalsVisibleTo to Marathon.Infrastructure.csproj.
2. Phase 5: LocalizationOptions namespace ambiguity (AspNetCore vs Extensions).
3. Phase 5: WpfBlazor Serilog API mismatch.
Reviewer has NOT run on this batch. Move to Phase 4 only after build is green
and a combined parallel-batch reviewer passes.
74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using System.Text.Json.Nodes;
|
|
using Marathon.UI.Services;
|
|
|
|
namespace Marathon.UI.Tests;
|
|
|
|
public sealed class JsonSettingsWriterTests : IDisposable
|
|
{
|
|
private readonly string _tempPath = Path.Combine(Path.GetTempPath(), $"marathon-settings-{Guid.NewGuid():N}.json");
|
|
|
|
[Fact]
|
|
public async Task Save_writes_section_and_creates_file()
|
|
{
|
|
var writer = new JsonSettingsWriter(_tempPath);
|
|
|
|
await writer.SaveSectionAsync("Localization", new LocalizationOptions { DefaultCulture = "en-US" });
|
|
|
|
File.Exists(_tempPath).Should().BeTrue();
|
|
var json = await File.ReadAllTextAsync(_tempPath);
|
|
json.Should().Contain("\"DefaultCulture\"");
|
|
json.Should().Contain("\"en-US\"");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Save_preserves_other_sections()
|
|
{
|
|
await File.WriteAllTextAsync(_tempPath, "{\"Untouched\":{\"Value\":42}}");
|
|
|
|
var writer = new JsonSettingsWriter(_tempPath);
|
|
await writer.SaveSectionAsync("Localization", new LocalizationOptions { DefaultCulture = "ru-RU" });
|
|
|
|
var root = await writer.ReadAllAsync();
|
|
root["Untouched"].Should().NotBeNull();
|
|
root["Untouched"]!["Value"]!.GetValue<int>().Should().Be(42);
|
|
root["Localization"]!["DefaultCulture"]!.GetValue<string>().Should().Be("ru-RU");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Reset_removes_section_only()
|
|
{
|
|
var writer = new JsonSettingsWriter(_tempPath);
|
|
await writer.SaveSectionAsync("A", new { X = 1 });
|
|
await writer.SaveSectionAsync("B", new { Y = 2 });
|
|
|
|
await writer.ResetSectionAsync("A");
|
|
|
|
var root = await writer.ReadAllAsync();
|
|
root.ContainsKey("A").Should().BeFalse();
|
|
root.ContainsKey("B").Should().BeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Reset_when_file_missing_is_a_no_op()
|
|
{
|
|
var writer = new JsonSettingsWriter(_tempPath);
|
|
await writer.ResetSectionAsync("Anything");
|
|
File.Exists(_tempPath).Should().BeFalse();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
try
|
|
{
|
|
if (File.Exists(_tempPath))
|
|
{
|
|
File.Delete(_tempPath);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
// best effort
|
|
}
|
|
}
|
|
}
|