Write the first test

This commit is contained in:
Sven van Heugten 2026-01-04 09:09:50 +01:00
parent fc069edf31
commit 109ebde64a
3 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,20 @@
module NightLight.Core.Tests.NightLightTests
open FsCheck.Xunit
let private assertIsOk (result: Result<unit, 'a>) : unit =
match result with
| Ok() -> ()
| Error error -> failwith $"Expected Ok, got Error {error}"
[<Property(Arbitrary = [| typeof<Arbitraries> |])>]
let ``Brightness should always be under 255`` (fakeHome: FakeHome) (interactions: Interaction list) =
interactions
|> Seq.iter (fun interaction -> fakeHome.Interact interaction |> assertIsOk)
fakeHome.LightStates
|> Seq.choose (fun (_, state) ->
match state with
| On brightness -> Some brightness
| Off -> None)
|> Seq.forall (fun brightness -> brightness < 255uy)