private void turnOnOrOff(Socket socket, PowerStatus status, string condition, string message, object sender) { if (status != PowerStatus.Undefined) { _stateStore.SetPhysicalState(socket, status); _sensorHub.OnPhysicalStatusHasChanged(sender, new StatusChangedEventArgs(message, condition, socket, status)); switch (status) { case PowerStatus.On: _controllerHub.TurnOn(socket); break; case PowerStatus.Off: _controllerHub.TurnOff(socket); break; } } }
public void TurnOff() { var socket = new Socket(1, "Toster"); var controllerOne = new Mock <IController>(); controllerOne.Setup(x => x.TurnOff(socket)); var controllerTwo = new Mock <IController>(); controllerTwo.Setup(x => x.TurnOff(socket)); var controllerHub = new ControllerHub(new List <IController> { controllerOne.Object, controllerTwo.Object }); controllerHub.TurnOff(socket); controllerOne.Verify(x => x.TurnOff(socket), Times.Once); controllerTwo.Verify(x => x.TurnOff(socket), Times.Once); }