namespace LivingVillage.Desktop.Tests open Microsoft.VisualStudio.TestTools.UnitTesting open Microsoft.Xna.Framework open LivingVillage.Desktop open LivingVillage.Kernel open LivingVillage.Kernel.Sim /// P73 回归:四时段光照档参数表完整性 + 与既有连续光照/时段标签一致。 [] type P73LightingTierTests () = let ticksPerHour = Sim.ticksPerDay / 24L let atHour hour = int64 hour * ticksPerHour [] member _.PeriodTableCoversFourDistinctTiers () = let periods = [ M6Presentation.Morning; M6Presentation.Noon; M6Presentation.Dusk; M6Presentation.Night ] let stated = periods |> List.map (fun p -> let l = M6Presentation.periodLighting p (p, l.AmbientTint.R, l.AmbientTint.G, l.AmbientTint.B, l.Veil.R, l.Veil.G, l.Veil.B, l.VeilAlpha, l.LanternGlow)) // 四档两两不同(色调/覆盖色/alpha/灯光至少一项相异)。 Assert.AreEqual(4, stated |> List.map (fun (_, r, g, b, vr, vg, vb, a, glow) -> (r, g, b, vr, vg, vb, a, glow)) |> List.distinct |> List.length) // 名称表覆盖全四档。 let names = periods |> List.map M6Presentation.lightingPeriodName Assert.AreEqual(4, names |> List.distinct |> List.length) Assert.IsTrue(names |> List.forall (fun n -> n <> "")) [] member _.NoonTierIsIdentityAndNightLightsLanterns () = let noon = M6Presentation.periodLighting M6Presentation.Noon Assert.AreEqual(255, int noon.AmbientTint.R) Assert.AreEqual(255, int noon.AmbientTint.G) Assert.AreEqual(255, int noon.AmbientTint.B) Assert.AreEqual(0, noon.VeilAlpha) Assert.AreEqual(0.0f, noon.LanternGlow) let night = M6Presentation.periodLighting M6Presentation.Night Assert.AreEqual(1.0f, night.LanternGlow) let dusk = M6Presentation.periodLighting M6Presentation.Dusk Assert.IsTrue(dusk.LanternGlow >= 0.3f, "黄昏须开始点亮路灯/灯笼") // 实际灯光强度:夜晚点亮,正午熄灭。 Assert.IsTrue(M6Presentation.effectiveLanternGlow (atHour 22) >= 1.0f) Assert.AreEqual(0.0f, M6Presentation.effectiveLanternGlow (atHour 12)) [] member _.PeriodAtTickMatchesRequestedHoursAndExistingLabels () = Assert.AreEqual(M6Presentation.Morning, M6Presentation.periodAtTick (atHour 6)) Assert.AreEqual(M6Presentation.Noon, M6Presentation.periodAtTick (atHour 12)) Assert.AreEqual(M6Presentation.Dusk, M6Presentation.periodAtTick (atHour 18)) Assert.AreEqual(M6Presentation.Night, M6Presentation.periodAtTick (atHour 22)) // 边界与既有 timePeriodLabel 完全一致:清晨↔清晨、正午↔白天、黄昏↔黄昏、夜晚↔夜晚。 let expectedLabel period = match period with | M6Presentation.Morning -> "清晨" | M6Presentation.Noon -> "白天" | M6Presentation.Dusk -> "黄昏" | M6Presentation.Night -> "夜晚" for hour in 0 .. 23 do let label = M6Presentation.timePeriodLabel (atHour hour) Assert.AreEqual(expectedLabel (M6Presentation.periodAtTick (atHour hour)), label) // 乘法色调:白色恒等。 let day = M6Presentation.profileAtTick (atHour 12) Assert.AreEqual(day.WorldTint, M6Presentation.multiplyTint day.WorldTint (M6Presentation.periodLighting M6Presentation.Noon).AmbientTint)