Implement FakeHome

This commit is contained in:
Sven van Heugten 2026-01-03 20:55:45 +01:00
parent 83b716a509
commit fc069edf31
4 changed files with 150 additions and 0 deletions

View file

@ -0,0 +1,28 @@
namespace NightLight.Core.Tests
open System
open System.Collections.Generic
open FsToolkit.ErrorHandling
open NightLight.Core.Models
open NightLight.Core.Core
type NightLightStateMachine(now: DateTime) =
let mutable state = { Time = now }
let transmittedCommands = new List<Message>()
let sendEvent event =
result {
let! newState, commands = onEventReceived state event
state <- newState
transmittedCommands.AddRange commands
}
member _.TransmittedCommands = transmittedCommands.AsReadOnly()
member _.SendMessage message =
ReceivedZigbeeEvent message |> sendEvent
member _.ChangeTime time = TimeChanged time |> sendEvent
member _.ClearTransmittedCommands() = transmittedCommands.Clear()