1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
namespace LivingVillage.Desktop.Tests
open Microsoft.VisualStudio.TestTools.UnitTesting
open Microsoft.Xna.Framework
open LivingVillage.Desktop
open LivingVillage.Kernel
open LivingVillage.Kernel.Sim
/// P73 回归:四时段光照档参数表完整性 + 与既有连续光照/时段标签一致。
[<TestClass>]
type P73LightingTierTests () =
let ticksPerHour = Sim.ticksPerDay / 24L
let atHour hour = int64 hour * ticksPerHour
[<TestMethod>]
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<int>(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<int>(4, names |> List.distinct |> List.length)
Assert.IsTrue(names |> List.forall (fun n -> n <> ""))
[<TestMethod>]
member _.NoonTierIsIdentityAndNightLightsLanterns () =
let noon = M6Presentation.periodLighting M6Presentation.Noon
Assert.AreEqual<int>(255, int noon.AmbientTint.R)
Assert.AreEqual<int>(255, int noon.AmbientTint.G)
Assert.AreEqual<int>(255, int noon.AmbientTint.B)
Assert.AreEqual<int>(0, noon.VeilAlpha)
Assert.AreEqual<float32>(0.0f, noon.LanternGlow)
let night = M6Presentation.periodLighting M6Presentation.Night
Assert.AreEqual<float32>(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<float32>(0.0f, M6Presentation.effectiveLanternGlow (atHour 12))
[<TestMethod>]
member _.PeriodAtTickMatchesRequestedHoursAndExistingLabels () =
Assert.AreEqual<M6Presentation.M6Period>(M6Presentation.Morning, M6Presentation.periodAtTick (atHour 6))
Assert.AreEqual<M6Presentation.M6Period>(M6Presentation.Noon, M6Presentation.periodAtTick (atHour 12))
Assert.AreEqual<M6Presentation.M6Period>(M6Presentation.Dusk, M6Presentation.periodAtTick (atHour 18))
Assert.AreEqual<M6Presentation.M6Period>(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<string>(expectedLabel (M6Presentation.periodAtTick (atHour hour)), label)
// 乘法色调:白色恒等。
let day = M6Presentation.profileAtTick (atHour 12)
Assert.AreEqual<Color>(day.WorldTint, M6Presentation.multiplyTint day.WorldTint (M6Presentation.periodLighting M6Presentation.Noon).AmbientTint)
|