summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Desktop.Tests
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-20 14:20:54 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-20 14:20:54 +0800
commit7e197babfbb68d7f7d1866d6a0ca47cf17d3af23 (patch)
treeabf951825edce69139f099a73dfb6f2575ff0259 /src/LivingVillage.Desktop.Tests
parent4f8aca922e6cf47dce95aab79541065d487d5272 (diff)
downloadliving-village-7e197babfbb68d7f7d1866d6a0ca47cf17d3af23.tar.gz
feat(m5): 增加可交互对话、需求观察与编年史
[变更性质] - 本提交新增 M5 用户能力,不是缺陷修复。 [新增功能] - 增加玩家六意图对话、需求面板、可见 NPC 观察、编年史与因果谣言冒烟验收。 [实现方案] - 在 Kernel 中扩展 Avatar Mind、对话结果、观察数据、Annals 和确定性谣言链。 - 在 Desktop 中加入键盘交互、像素文本面板和运行时状态展示,并补充 Headless 与测试覆盖。 [影响范围] - 覆盖 Kernel、Headless、Desktop 及测试工程;保留既有 M3/M4 确定性与交易、关系、谣言行为。
Diffstat (limited to 'src/LivingVillage.Desktop.Tests')
-rw-r--r--src/LivingVillage.Desktop.Tests/DesktopTests.fs63
-rw-r--r--src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj23
2 files changed, 86 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/DesktopTests.fs b/src/LivingVillage.Desktop.Tests/DesktopTests.fs
new file mode 100644
index 0000000..ffcc6c0
--- /dev/null
+++ b/src/LivingVillage.Desktop.Tests/DesktopTests.fs
@@ -0,0 +1,63 @@
+namespace LivingVillage.Desktop.Tests
+
+open Microsoft.VisualStudio.TestTools.UnitTesting
+open LivingVillage.Kernel
+open LivingVillage.Kernel.Sim
+open LivingVillage.Desktop
+
+module private Harness =
+
+ let atNpc (id: int) (world: World) : World =
+ let npc = world.Npcs.[id]
+ { world with Avatar = { world.Avatar with Pos = npc.Pos } }
+
+[<TestClass>]
+type DesktopTests () =
+
+ [<TestMethod>]
+ member _.InteractOpensTheSixIntentMenu () =
+ let world = Sim.initialWorldN 42UL 4 |> Harness.atNpc 0
+ let next, view = M5Interaction.apply Interact world M5Interaction.initial
+
+ 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"))
+
+ [<TestMethod>]
+ member _.SelectingAnIntentUpdatesWorldAndChronicle () =
+ let world = Sim.initialWorldN 42UL 4 |> Harness.atNpc 0
+ let openedWorld, opened = M5Interaction.apply Interact world M5Interaction.initial
+ let next, view = M5Interaction.apply Intent1 openedWorld opened
+
+ Assert.IsTrue(next.Events |> List.exists (fun event ->
+ match event.Kind with
+ | DialogueEvent _ -> true
+ | _ -> false))
+ Assert.IsTrue(next.Annals |> List.exists (fun entry ->
+ match entry.Kind with
+ | DialogueAnnal _ -> true
+ | _ -> false))
+ Assert.IsTrue(view.Chronicle.Contains("dialogue"))
+ Assert.IsTrue(view.Status.Contains("dialogue"))
+
+ [<TestMethod>]
+ member _.NeedsAndObservationPanelsUseKernelViews () =
+ let world = Sim.initialWorldN 42UL 4 |> Harness.atNpc 0
+ let afterStep = Sim.step { Input = { MoveX = 0.0f; MoveY = 0.0f } } world
+ let _, needsView = M5Interaction.apply ToggleNeeds afterStep M5Interaction.initial
+ let _, observationView = M5Interaction.apply Observe world M5Interaction.initial
+
+ Assert.AreEqual<Needs>(afterStep.Avatar.Mind.Needs, needsView.Needs.Value.Needs)
+ Assert.IsTrue(observationView.Observations |> List.exists (fun observation -> observation.Id = NpcId 0))
+
+ [<TestMethod>]
+ member _.HeadlessSmokeProvesTheThreeHopCausalChain () =
+ let result = Program.M5Smoke.run ()
+
+ Assert.IsTrue(result.Passed, result.Failure)
+ Assert.AreEqual<int>(6, result.MenuOptions)
+ Assert.AreEqual<int>(4, result.RumorPathLength)
+ Assert.IsTrue(result.Chronicle.Contains("dialogue"))
+ Assert.IsTrue(result.RumorTrace.Contains("receiver=-1"))
+ Assert.IsTrue(result.RumorTrace.Contains("depth=3"))
diff --git a/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj b/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj
new file mode 100644
index 0000000..a1cbe33
--- /dev/null
+++ b/src/LivingVillage.Desktop.Tests/LivingVillage.Desktop.Tests.fsproj
@@ -0,0 +1,23 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net8.0</TargetFramework>
+ <IsPackable>false</IsPackable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Compile Include="DesktopTests.fs" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
+ <PackageReference Include="MSTest.TestAdapter" Version="3.6.3" />
+ <PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\LivingVillage.Desktop\LivingVillage.Desktop.fsproj" />
+ <ProjectReference Include="..\LivingVillage.Headless\LivingVillage.Headless.fsproj" />
+ </ItemGroup>
+
+</Project>