From 275a0677eb92fc35411c68ce4a8faa72bd5f19f1 Mon Sep 17 00:00:00 2001 From: Sven van Heugten Date: Sat, 17 Jan 2026 11:30:55 +0100 Subject: [PATCH] Add test for light brightness --- NightLight.Core.Tests/NightLightTests.fs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/NightLight.Core.Tests/NightLightTests.fs b/NightLight.Core.Tests/NightLightTests.fs index e2077cf..376e86c 100644 --- a/NightLight.Core.Tests/NightLightTests.fs +++ b/NightLight.Core.Tests/NightLightTests.fs @@ -40,6 +40,23 @@ type NightLightTests() = |> Prop.collect $"{fakeHome.LightsThatAreOn.Length} light(s) on" |> Prop.trivial (fakeHome.LightsThatAreOn.Length = 0) + [ |])>] + let ``All lights should either be off or have a brightness that fits its color`` (interactions: Interaction list) = + let fakeHome = createFakeHomeWithNightLightAndInteract interactions + + fakeHome.LightStates + |> Seq.forall (function + | _, Off + | { Bulb = IkeaBulb }, On(254uy, White) -> true + | { Bulb = IkeaBulb }, On(210uy, Yellow) -> true + | { Bulb = IkeaBulb }, On(254uy, Red) -> true + | { Bulb = PaulmannBulb }, On(35uy, White) -> true + | { Bulb = PaulmannBulb }, On(35uy, Yellow) -> true + | { Bulb = PaulmannBulb }, On(80uy, Red) -> true + | _ -> false) + |> Prop.collect $"{fakeHome.LightsThatAreOn.Length} light(s) on" + |> Prop.trivial (fakeHome.LightsThatAreOn.Length = 0) + [ |])>] let ``All non-remotely controlled lights with power should be on`` (interactions: Interaction list) = let fakeHome = createFakeHomeWithNightLightAndInteract interactions