diff options
Diffstat (limited to 'src/LivingVillage.Desktop.Tests/DesktopTests.fs')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/DesktopTests.fs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/DesktopTests.fs b/src/LivingVillage.Desktop.Tests/DesktopTests.fs index e9713e5..52443e9 100644 --- a/src/LivingVillage.Desktop.Tests/DesktopTests.fs +++ b/src/LivingVillage.Desktop.Tests/DesktopTests.fs @@ -156,3 +156,55 @@ type DesktopTests () = Assert.AreEqual<int64>(0L, defaultWorld.Tick) Assert.AreEqual<float>(0.0, defaultWorld.Time) Assert.AreEqual<M6DayNight>(Night, defaultProfile.Mode) + +// ---- P12 中文每日任务面板 ---- + +module private TaskPanelHarness = + + let occupationWithTask (taskState: Occupation.TaskState) : Occupation.State = + let occupation = Occupation.stateOf Occupation.Farmer + let task = + (Occupation.dailyTaskOf 42UL 7UL 0L Occupation.Farmer).Value + |> Occupation.acceptTask + |> fun active -> if taskState = Occupation.Done then { active with State = Occupation.Done } else { active with State = taskState } + { occupation with Today = Some task } + +[<TestClass>] +type TaskPanelTests () = + + [<TestMethod>] + member _.TaskPanelWithoutOccupationShowsNoOccupationLine () = + let world = Sim.initialWorldN 42UL 4 + let _, view = M5Interaction.apply ShowTaskPanel world M5Interaction.initial + + Assert.AreEqual<M5Panel>(TaskPanel, view.Panel) + Assert.AreEqual<string>("task", M5Interaction.panelName view) + let lines = M5Interaction.panelLines world view + Assert.IsTrue(lines |> List.contains "任务", "panel heading expected") + Assert.IsTrue(lines |> List.contains "无职业") + + [<TestMethod>] + member _.TaskPanelShowsChineseOccupationNameAndTheThreeStates () = + let world = Sim.initialWorldN 42UL 4 + for taskState, expected in [ Occupation.Offered, "待接受"; Occupation.Active, "进行中"; Occupation.Done, "已完成" ] do + let withTask = { M5Interaction.initial with Task = Some (TaskPanelHarness.occupationWithTask taskState) } + let _, view = M5Interaction.apply ShowTaskPanel world withTask + let lines = M5Interaction.panelLines world view + Assert.IsTrue(lines |> List.contains "农夫", $"occupation name missing for {taskState}") + Assert.IsTrue(lines |> List.exists (fun line -> line.Contains(expected)), $"state {expected} missing in {lines}") + + [<TestMethod>] + member _.TaskPanelTitleUsesChineseHeading () = + let world = Sim.initialWorldN 42UL 4 + let _, view = M5Interaction.apply ShowTaskPanel world M5Interaction.initial + Assert.IsTrue(M5Interaction.titleText view |> fun text -> text.Contains("任务")) + + [<TestMethod>] + member _.ShowTaskPanelIsRejectedFromDialoguePanelLikeOtherOverlays () = + let world = Sim.initialWorldN 42UL 4 |> Harness.atNpc 0 + let openedWorld, dialogueView = M5Interaction.apply Interact world M5Interaction.initial + let _, afterTask = M5Interaction.apply ShowTaskPanel openedWorld dialogueView + + Assert.AreEqual<M5View>(dialogueView, afterTask) + let _, closed = M5Interaction.apply ClosePanel world { dialogueView with Panel = TaskPanel } + Assert.AreEqual<M5Panel>(WorldPanel, closed.Panel) |
