diff options
Diffstat (limited to 'src/LivingVillage.Desktop.Tests')
| -rw-r--r-- | src/LivingVillage.Desktop.Tests/PrototypeTests.fs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs index 3abb064..a4bd1ea 100644 --- a/src/LivingVillage.Desktop.Tests/PrototypeTests.fs +++ b/src/LivingVillage.Desktop.Tests/PrototypeTests.fs @@ -5,6 +5,8 @@ open Microsoft.VisualStudio.TestTools.UnitTesting open LivingVillage.Kernel open LivingVillage.Kernel.Sim open LivingVillage.Desktop +open LivingVillage.Desktop.ChineseText +open LivingVillage.Desktop.VillageArt open LivingVillage.Desktop.VillagePresentation [<TestClass>] @@ -176,3 +178,73 @@ type PrototypeTests () = 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 }) + + [<TestMethod>] + member _.JiangnanArtPlanIsDeterministicAndContainsRequiredElements () = + let first = samplePlan () + let second = samplePlan () + let requiredProps = + [ VillageArt.WhiteWallDarkTileHouse + VillageArt.StoneBridge + VillageArt.Bamboo + VillageArt.VegetableGarden ] + + Assert.AreEqual<JiangnanArtPlan>(first, second) + Assert.IsTrue( + requiredProps + |> List.forall (fun prop -> first.Props |> List.exists (fun sprite -> sprite.Kind = prop)), + "The Jiangnan plan is missing one or more required props.") + Assert.IsTrue(first.Tiles |> List.exists (fun tile -> tile.Kind = (VillageArt.RiverWater))) + Assert.IsTrue(first.Tiles |> List.exists (fun tile -> tile.Kind = (VillageArt.StonePaving))) + + [<TestMethod>] + member _.NpcVariantsAreStableAndAnimationCoversFourDirectionsAndTwoFrames () = + let sameNpc = npcVisualVariant (NpcId 7) + let repeatedNpc = npcVisualVariant (NpcId 7) + let otherNpc = npcVisualVariant (NpcId 8) + let directions = + [ NorthFacing + SouthFacing + WestFacing + EastFacing ] + let sprites = directions |> List.map (fun direction -> npcSpriteSpec (NpcId 7) direction 4L) + + Assert.AreEqual<NpcVisualVariant>(sameNpc, repeatedNpc) + Assert.AreNotEqual<NpcVisualVariant>(sameNpc, otherNpc) + Assert.AreEqual<int>(4, sprites |> List.map (fun sprite -> sprite.Direction) |> List.distinct |> List.length) + Assert.IsTrue(sprites |> List.forall (fun sprite -> sprite.Frame = FrameTwo)) + Assert.AreEqual<AnimationFrame>(FrameOne, (VillageArt.animationFrame 0L)) + Assert.AreEqual<AnimationFrame>(FrameTwo, (VillageArt.animationFrame 4L)) + Assert.AreEqual<AnimationFrame>(FrameOne, (VillageArt.animationFrame 8L)) + + [<TestMethod>] + member _.ChineseCopyProvidesFormalSceneTimeMenuAndStatusLabels () = + let labels = + [ sceneLabel VillageScene + sceneLabel Waterway + sceneLabel WhiteWallHome + sceneLabel StoneBridgeScene + sceneLabel BambooGrove + sceneLabel VegetableGardenScene + dayNightLabel DayTime + dayNightLabel NightTime + menuHeading MainMenuHeading + menuHeading SettingsHeading + menuHeading ControlsHeading + statusHeading StatusHeading + statusHeading ReadyStatus + statusHeading PausedStatus ] + + Assert.IsTrue(labels |> List.forall (fun label -> not (String.IsNullOrWhiteSpace label))) + Assert.IsTrue(labels |> List.forall (fun label -> not (label.Contains("?")))) + Assert.AreEqual<string>("江南水乡", copy.SceneTitle) + Assert.AreEqual<string>("准备就绪", copy.Ready) + + [<TestMethod>] + member _.ChineseTextWrapsAndUsesAnExplicitMissingGlyphPolicy () = + let supported = Set.ofList [ '江'; '南'; '水'; '乡' ] + let layout = layoutText 4 supported "江南水乡村" + + Assert.AreEqual<string list>([ "江南水乡"; "□" ], layout.Lines) + Assert.AreEqual<char list>([ '村' ], layout.MissingGlyphs) + Assert.IsFalse(String.concat "" layout.Lines |> fun text -> text.Contains("?")) |
