From 020b54142a2929ad73888d15639cdd5ed823754b Mon Sep 17 00:00:00 2001 From: SeoJCalive <180237232+SeoJCalive@users.noreply.github.com> Date: Thu, 29 Oct 2026 00:19:26 +0900 Subject: [PATCH] test(setup): check a language switch through ApplyLook shows the new texts Follow-up to #667 / #692. Through the real App.ApplyLook, SetLanguage("ko") changes both the app resource and a bound TextBlock in a shown window, and the switch raises at most 10 resource changes: one for the texts plus the fixed font and flow-direction changes, none of which grows with the number of keys. One write per key fails it with over a thousand. --- tests/Filee.Setup.Tests/SetupTextsTests.cs | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/Filee.Setup.Tests/SetupTextsTests.cs b/tests/Filee.Setup.Tests/SetupTextsTests.cs index e8427add2..9e2d86371 100644 --- a/tests/Filee.Setup.Tests/SetupTextsTests.cs +++ b/tests/Filee.Setup.Tests/SetupTextsTests.cs @@ -142,6 +142,41 @@ public void Publishing_a_language_switch_raises_one_resource_change() } } + [AvaloniaFact] + public void A_language_switch_through_apply_look_shows_the_new_texts() + { + var app = Application.Current!; + var texts = new SetupTexts("en"); + App.ApplyLook(app, texts); + var block = new TextBlock(); + block.Bind(TextBlock.TextProperty, block.GetResourceObservable("installer.install")); + var window = new Window { Content = block }; + window.Show(); + var changes = 0; + void Count(object? sender, ResourcesChangedEventArgs e) => changes++; + try + { + Assert.Equal("Install", block.Text); + + app.ResourcesChanged += Count; + texts.SetLanguage("ko"); + + var korean = new SetupTexts("ko")["installer.install"]; + Assert.True(app.TryGetResource("installer.install", null, out var install)); + Assert.Equal(korean, install); + Assert.Equal(korean, block.Text); + // The texts are one change; the font and the flow direction add a few more. None of them grows with the + // number of keys (one change per key was over a thousand). + Assert.InRange(changes, 1, 10); + } + finally + { + window.Close(); + app.ResourcesChanged -= Count; + texts.SetLanguage("en"); + } + } + [Fact] public void Every_key_setup_uses_exists_in_english() {