Inheritance: IBinaryStateEndpoint
Exemplo n.º 1
0
        public void TurnOnAndTurnOff_Socket()
        {
            var endpoint = new TestBinaryStateEndpoint();
            var socket = new Socket(ComponentIdGenerator.EmptyId, endpoint);
            socket.ResetState();

            endpoint.TurnOnCalledCount.ShouldBeEquivalentTo(0);
            endpoint.TurnOffCalledCount.ShouldBeEquivalentTo(1);
            socket.GetState().ShouldBeEquivalentTo(BinaryStateId.Off);

            socket.TryTurnOn();
            endpoint.TurnOnCalledCount.ShouldBeEquivalentTo(1);
            endpoint.TurnOffCalledCount.ShouldBeEquivalentTo(1);
            socket.GetState().ShouldBeEquivalentTo(BinaryStateId.On);

            socket.TryTurnOn();
            endpoint.TurnOnCalledCount.ShouldBeEquivalentTo(1);
            endpoint.TurnOffCalledCount.ShouldBeEquivalentTo(1);
            socket.GetState().ShouldBeEquivalentTo(BinaryStateId.On);

            socket.TryTurnOff();
            endpoint.TurnOnCalledCount.ShouldBeEquivalentTo(1);
            endpoint.TurnOffCalledCount.ShouldBeEquivalentTo(2);
            socket.GetState().ShouldBeEquivalentTo(BinaryStateId.Off);

            socket.TryTurnOff();
            endpoint.TurnOnCalledCount.ShouldBeEquivalentTo(1);
            endpoint.TurnOffCalledCount.ShouldBeEquivalentTo(2);
            socket.GetState().ShouldBeEquivalentTo(BinaryStateId.Off);

            socket.TryTurnOn();
            endpoint.TurnOnCalledCount.ShouldBeEquivalentTo(2);
            endpoint.TurnOffCalledCount.ShouldBeEquivalentTo(2);
            socket.GetState().ShouldBeEquivalentTo(BinaryStateId.On);
        }
Exemplo n.º 2
0
        public void StateAlias_Lamp()
        {
            var endpoint = new TestBinaryStateEndpoint();
            var lamp = new Lamp(ComponentIdGenerator.EmptyId, endpoint);
            lamp.ResetState();

            lamp.SetStateIdAlias(BinaryStateId.On, LevelStateId.Level1);

            endpoint.TurnOnCalledCount.ShouldBeEquivalentTo(0);
            endpoint.TurnOffCalledCount.ShouldBeEquivalentTo(1);
            lamp.GetState().ShouldBeEquivalentTo(BinaryStateId.Off);

            lamp.SetState(LevelStateId.Level1);
            endpoint.TurnOnCalledCount.ShouldBeEquivalentTo(1);
            endpoint.TurnOffCalledCount.ShouldBeEquivalentTo(1);
            lamp.GetState().ShouldBeEquivalentTo(BinaryStateId.On);
        }