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 TurnOn() { var socket = new Socket(1, "Toster"); var controllerOne = new Mock <IController>(); controllerOne.Setup(x => x.TurnOn(socket)); var controllerTwo = new Mock <IController>(); controllerTwo.Setup(x => x.TurnOn(socket)); var controllerHub = new ControllerHub(new List <IController> { controllerOne.Object, controllerTwo.Object }); controllerHub.TurnOn(socket); controllerOne.Verify(x => x.TurnOn(socket), Times.Once); controllerTwo.Verify(x => x.TurnOn(socket), Times.Once); }