diff --git a/NightLight.Core.Tests/NightLightTests.fs b/NightLight.Core.Tests/NightLightTests.fs index cfbc25f..c1aab89 100644 --- a/NightLight.Core.Tests/NightLightTests.fs +++ b/NightLight.Core.Tests/NightLightTests.fs @@ -124,7 +124,10 @@ type NightLightTests() = (fun state interaction -> match state, interaction with | _, RemotePressedOffButton -> BothOff - | _, RemotePressedOnButton -> BothOn + | BothOff, RemotePressedOnButton -> BothOn + | BothOn, RemotePressedOnButton -> LeftOn + | LeftOn, RemotePressedOnButton -> RightOn + | RightOn, RemotePressedOnButton -> BothOn | _, RemotePressedLeftButton -> LeftOn) BothOn diff --git a/NightLight.Core/NightLightStateMachine.fs b/NightLight.Core/NightLightStateMachine.fs index 4ed8d9e..73a3169 100644 --- a/NightLight.Core/NightLightStateMachine.fs +++ b/NightLight.Core/NightLightStateMachine.fs @@ -95,8 +95,13 @@ type NightLightStateMachine private (maybeState: NightLightState option) = | PressedOn -> currentState |> withAlarmOff - |> withStateFor RightBedroomLamp On - |> withStateFor LeftBedroomLamp On + |> match + currentState.LightToManualState[LeftBedroomLamp], + currentState.LightToManualState[RightBedroomLamp] + with + | Off, _ -> withStateFor LeftBedroomLamp On >> withStateFor RightBedroomLamp On + | On, On -> withStateFor LeftBedroomLamp On >> withStateFor RightBedroomLamp Off + | On, Off -> withStateFor LeftBedroomLamp Off >> withStateFor RightBedroomLamp On | PressedOff -> currentState |> withAlarmOff