diff options
Diffstat (limited to 'src/LivingVillage.Desktop.Tests/P16UiTests.fs')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/P16UiTests.fs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/P16UiTests.fs b/src/LivingVillage.Desktop.Tests/P16UiTests.fs new file mode 100644 index 0000000..0bfdb62 --- /dev/null +++ b/src/LivingVillage.Desktop.Tests/P16UiTests.fs @@ -0,0 +1,66 @@ +namespace LivingVillage.Desktop.Tests + +open Microsoft.VisualStudio.TestTools.UnitTesting +open LivingVillage.Kernel +open LivingVillage.Desktop + +// ---- P16 启动画面 / 开始界面 ---- + +[<TestClass>] +type P16LaunchTests () = + + [<TestMethod>] + member _.LaunchRevealAndVeilAreDeterministicAndComplete () = + Assert.AreEqual<float32>(0.0f, LaunchScreen.revealProgress 0L) + Assert.AreEqual<float32>(1.0f, LaunchScreen.revealProgress LaunchScreen.fadeInFrames) + Assert.AreEqual<float32>(1.0f, LaunchScreen.revealProgress 1000L) + Assert.AreEqual<float32>(1.0f, LaunchScreen.veilAlpha 0L) + Assert.AreEqual<float32>(0.0f, LaunchScreen.veilAlpha LaunchScreen.durationFrames) + Assert.IsTrue(LaunchScreen.veilAlpha 30L > LaunchScreen.veilAlpha 90L, "veil must decrease monotonically") + Assert.IsFalse(LaunchScreen.isComplete (LaunchScreen.durationFrames - 1L)) + Assert.IsTrue(LaunchScreen.isComplete LaunchScreen.durationFrames) + + [<TestMethod>] + member _.LaunchSkipIsEscOrSpaceAndTextUsesTheAtlasPath () = + Assert.IsTrue(LaunchScreen.skipRequested true false) + Assert.IsTrue(LaunchScreen.skipRequested false true) + Assert.IsFalse(LaunchScreen.skipRequested false false) + Assert.IsTrue(PixelText.isRenderable LaunchScreen.title) + Assert.IsTrue(PixelText.isRenderable LaunchScreen.skipHint) + Assert.IsTrue(PixelText.isRenderable LaunchScreen.subtitle) + Assert.IsTrue(ChineseText.requiredUiLabels |> List.contains LaunchScreen.skipHint) + +[<TestClass>] +type P16StartMenuTests () = + + [<TestMethod>] + member _.StartMenuIsExactlyThreeItemsWithChineseLabels () = + let state = MenuState.create SimulationControl.initial false + + Assert.AreEqual<int>(3, MenuState.items state |> List.length) + Assert.AreEqual<string list>([ "开始"; "读档"; "退出" ], MenuState.items state |> List.map MenuState.itemLabel) + + [<TestMethod>] + member _.StartMenuNavigationSelectsEachItemAndWraps () = + let state = MenuState.create SimulationControl.initial false + let down1 = MenuState.move Down state + let down2 = MenuState.move Down down1 + let wrap = MenuState.move Down down2 + + Assert.AreEqual<MenuItem>(NewGameItem, MenuState.selectedItem state) + Assert.AreEqual<MenuItem>(LoadItem, MenuState.selectedItem down1) + Assert.AreEqual<MenuItem>(ExitItem, MenuState.selectedItem down2) + Assert.AreEqual<MenuItem>(NewGameItem, MenuState.selectedItem wrap) + + Assert.AreEqual<MenuCommand>(StartNewGame, MenuState.update Confirm state |> snd) + Assert.AreEqual<MenuCommand>(LoadGame, MenuState.update Confirm down1 |> snd) + Assert.AreEqual<MenuCommand>(ExitGame, MenuState.update Confirm down2 |> snd) + + [<TestMethod>] + member _.ReturningToMenuOffersContinueAsTheFirstOfThreeItems () = + let playing = MenuState.create SimulationControl.initial true |> MenuState.enterGame + let main = MenuState.openMain playing + + Assert.AreEqual<MenuItem list>([ ContinueItem; LoadItem; ExitItem ], MenuState.items main) + Assert.AreEqual<string list>([ "继续"; "读档"; "退出" ], MenuState.items main |> List.map MenuState.itemLabel) + Assert.AreEqual<MenuCommand>(ContinueGame, MenuState.update Confirm main |> snd) |
