예제 #1
0
        //RFID EVENT HANDLER
        private void RfidDetected(object sender, RFIDEventArgs e)
        {
            switch (_state)
            {
            case LadeskabState.Available:
                // Check for ladeforbindelse
                if (_charger.connected() && e.RFID > 0 && e.RFID <= 10000)
                {
                    _door.LockDoor();
                    _charger.startCharging();
                    _oldId = e.RFID;
                    _log.LockerLocklog(_oldId);
                    _display.StatusDoorLocked();
                    _state = LadeskabState.Locked;
                }
                else
                {
                    _display.FejlInPhoneConnection();
                }

                break;

            case LadeskabState.DoorOpen:
                // Ignore
                throw new System.Exception("ERROR! DOOR IS OPEN!!!!");

            case LadeskabState.Locked:
                // Check for correct ID
                CheckId(_oldId, e.RFID);

                break;
            }
        }//end RFID detected
        //Tests of: RFID events is received state Door Open
        public void RFIDDetected_StateDoorOpen_Throws()
        {
            uut._state = StationControl.LadeskabState.DoorOpen;
            ChargeFake.connected().Returns(false);

            void throwingFunc()
            {
                RFIDfake.RFIDEvent += Raise.EventWith(new RFIDEventArgs()
                {
                    RFID = 1
                });
            }

            Assert.Throws(typeof(System.Exception), throwingFunc);
        }