summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop.Tests
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-20 21:38:46 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-20 21:38:46 +0800
commitc64779031d8459c44d78916ab6e38e80d2532a1c (patch)
tree5cddbc68f3708ce58650ddd172483f5fe9e14fe0 /src/LivingVillage.Desktop.Tests
parentc5ff7685e5b3ac5dc46fce74ef1b302de09af1e6 (diff)
downloadliving-village-c64779031d8459c44d78916ab6e38e80d2532a1c.tar.gz
feat(desktop): localize village presentation labels
[Change Nature] - This commit adds the Chinese display layer for the desktop village prototype. [New Capability] - Menu, settings, controls, interaction panels, chronicle entries, trade results, day-night labels, and speed labels now use Chinese copy. [Implementation] - Keep simulation state, commands, and machine-readable status strings unchanged. - Add focused formatter coverage and update affected presentation assertions. [Impact] - Desktop presentation behavior is localized without changing Kernel or simulation logic. - Existing release build and test coverage remain green.
Diffstat (limited to 'src/LivingVillage.Desktop.Tests')
-rw-r--r--src/LivingVillage.Desktop.Tests/DesktopTests.fs2
-rw-r--r--src/LivingVillage.Desktop.Tests/M6aTests.fs8
-rw-r--r--src/LivingVillage.Desktop.Tests/PrototypeTests.fs76
3 files changed, 81 insertions, 5 deletions
diff --git a/src/LivingVillage.Desktop.Tests/DesktopTests.fs b/src/LivingVillage.Desktop.Tests/DesktopTests.fs
index 650f757..1c175ce 100644
--- a/src/LivingVillage.Desktop.Tests/DesktopTests.fs
+++ b/src/LivingVillage.Desktop.Tests/DesktopTests.fs
@@ -22,7 +22,7 @@ type DesktopTests () =
Assert.AreEqual<World>(world, next)
Assert.AreEqual<M5Panel>(DialoguePanel, view.Panel)
Assert.AreEqual<int>(6, view.Menu.Value.Options.Length)
- Assert.IsTrue(M5Interaction.titleText view |> fun text -> text.Contains("SMALLTALK"))
+ Assert.IsTrue(M5Interaction.titleText view |> fun text -> text.Contains("闲聊"))
[<TestMethod>]
member _.SelectingAnIntentUpdatesWorldAndChronicle () =
diff --git a/src/LivingVillage.Desktop.Tests/M6aTests.fs b/src/LivingVillage.Desktop.Tests/M6aTests.fs
index 1cc29d4..04920d4 100644
--- a/src/LivingVillage.Desktop.Tests/M6aTests.fs
+++ b/src/LivingVillage.Desktop.Tests/M6aTests.fs
@@ -9,7 +9,7 @@ type M6aDesktopTests () =
[<TestMethod>]
member _.SpeedLabelsExposePauseAndThreeRunningModes () =
- Assert.AreEqual<string>("PAUSED", M6Presentation.clockLabel { Paused = true; Speed = OneX })
- Assert.AreEqual<string>("1X", M6Presentation.clockLabel { Paused = false; Speed = OneX })
- Assert.AreEqual<string>("2X", M6Presentation.clockLabel { Paused = false; Speed = TwoX })
- Assert.AreEqual<string>("5X", M6Presentation.clockLabel { Paused = false; Speed = FiveX })
+ Assert.AreEqual<string>("暂停", M6Presentation.clockLabel { Paused = true; Speed = OneX })
+ Assert.AreEqual<string>("1倍速", M6Presentation.clockLabel { Paused = false; Speed = OneX })
+ Assert.AreEqual<string>("2倍速", M6Presentation.clockLabel { Paused = false; Speed = TwoX })
+ Assert.AreEqual<string>("5倍速", M6Presentation.clockLabel { Paused = false; Speed = FiveX })
diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
index b959d70..3abb064 100644
--- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
+++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs
@@ -1,7 +1,10 @@
namespace LivingVillage.Desktop.Tests
+open System
open Microsoft.VisualStudio.TestTools.UnitTesting
+open LivingVillage.Kernel
open LivingVillage.Kernel.Sim
+open LivingVillage.Desktop
open LivingVillage.Desktop.VillagePresentation
[<TestClass>]
@@ -100,3 +103,76 @@ type PrototypeTests () =
Assert.AreEqual<string>("需求", stageOneCopy.Needs)
Assert.AreEqual<string>("交易", stageOneCopy.Trade)
Assert.AreEqual<string>("进入民居", stageOneCopy.EnterHome)
+
+ [<TestMethod>]
+ member _.MenuControlsAndSettingsUseChineseDisplayCopy () =
+ let state = MenuState.create SimulationControl.initial false
+ let itemLabels = MenuState.items state |> List.map MenuState.itemLabel
+ let controlLabels = MenuState.controlRows |> List.map (fun row -> row.Action)
+ let settingsLabels = MenuState.settings |> List.map MenuState.settingsLabel
+
+ Assert.IsTrue(itemLabels |> List.contains "开始新游戏")
+ Assert.IsTrue(itemLabels |> List.contains "读取存档")
+ Assert.IsTrue(itemLabels |> List.contains "设置")
+ Assert.IsTrue(itemLabels |> List.contains "退出")
+ Assert.AreEqual<string list>(
+ [ "移动"
+ "互动"
+ "对话"
+ "观察"
+ "需求"
+ "年鉴"
+ "关系"
+ "暂停"
+ "速度"
+ "保存"
+ "读取"
+ "菜单或关闭"
+ "选择"
+ "确认" ],
+ controlLabels)
+ Assert.AreEqual<string list>([ "1倍速"; "2倍速"; "5倍速"; "暂停" ], settingsLabels)
+
+ [<TestMethod>]
+ member _.InteractionPanelsUseChineseLabelsAndExplicitTradeResults () =
+ let world = Sim.initialWorldN 42UL 4
+ let nearby =
+ { world with
+ Avatar = { world.Avatar with Pos = world.Npcs.[0].Pos } }
+ let openedWorld, opened = M5Interaction.apply Interact nearby M5Interaction.initial
+ let title = M5Interaction.titleText opened
+ let needsWorld, needsView = M5Interaction.apply ToggleNeeds openedWorld opened
+ let needsText = String.concat "|" (M5Interaction.panelLines needsWorld needsView)
+ let _, chronicleView = M5Interaction.apply ShowChronicle nearby M5Interaction.initial
+ let chronicleText = String.concat "|" (M5Interaction.panelLines nearby chronicleView)
+ let request =
+ { Buyer = NpcId 0
+ Seller = NpcId 1
+ Item = Food
+ Quantity = 1 }
+ let quote = Sim.quotePrice request nearby
+ let successText = M5Interaction.tradeResultText request quote (Sim.trade request nearby)
+ let failureRequest = { request with Quantity = 0 }
+ let failureText =
+ M5Interaction.tradeResultText failureRequest (Sim.quotePrice failureRequest nearby) (Sim.trade failureRequest nearby)
+
+ Assert.IsTrue(title.Contains("互动"))
+ Assert.IsTrue(title.Contains("闲聊"))
+ Assert.IsFalse(title.Contains("SMALLTALK"))
+ Assert.IsTrue(needsText.Contains("需求"))
+ Assert.IsTrue(needsText.Contains("饥饿"))
+ Assert.IsTrue(chronicleText.Contains("年鉴"))
+ Assert.IsTrue(chronicleText.Contains("暂无记录"))
+ Assert.IsTrue(successText.Contains("交易成功"))
+ Assert.IsTrue(successText.Contains("报价"))
+ Assert.IsTrue(failureText.Contains("交易失败"))
+ Assert.IsTrue(failureText.Contains("数量"))
+
+ [<TestMethod>]
+ member _.DayNightAndSpeedUseChineseDisplayCopy () =
+ Assert.AreEqual<string>("白天", M6Presentation.dayNightLabel Day)
+ Assert.AreEqual<string>("夜晚", M6Presentation.dayNightLabel Night)
+ Assert.AreEqual<string>("暂停", M6Presentation.clockLabel { Paused = true; Speed = OneX })
+ Assert.AreEqual<string>("1倍速", M6Presentation.clockLabel { Paused = false; Speed = OneX })
+ Assert.AreEqual<string>("2倍速", M6Presentation.clockLabel { Paused = false; Speed = TwoX })
+ Assert.AreEqual<string>("5倍速", M6Presentation.clockLabel { Paused = false; Speed = FiveX })