Exemplo n.º 1
0
        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;
                }
            }
        }
Exemplo n.º 2
0
        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);
        }