public void RfidDetected_NewRfidDetectedAvaliable_DoorIsLocked()
        {
            _fChargeControl.Connected().Returns(true);

            _fRfidReader.RfidDetectedEvent += Raise.EventWith(new RfidEventArgs {
                Id = 12
            });

            _fDoor.Received(1).LockDoor();
        }
Beispiel #2
0
 public void HandleDoorStatusEvent_DoorClosedAndChargerConnected_PrintCorrectMessage()
 {
     _charger.Connected().Returns(true);
     _door.DoorStatusChanged += Raise.EventWith(new DoorStateChangedEventArgs {
         IsOpen = false
     });
     _display.Received(1).Print("Swipe key");
 }
Beispiel #3
0
 private void HandleDoorStatusEvent(object sender, DoorStateChangedEventArgs e)
 {
     DoorState = e.IsOpen;
     if (DoorState)
     {
         _state = LadeskabState.DoorOpen;
         if (!_charger.Connected())
         {
             _display.Print("Connect phone");
         }
     }
     else
     {
         _state = LadeskabState.Available;
         if (_charger.Connected())
         {
             _display.Print("Swipe key");
         }
     }
 }
        // Eksempel på event handler for eventet "RFID Detected" fra tilstandsdiagrammet for klassen
        private void RfidDetected(object sender, RfidEventArgs e)
        {
            switch (_state)
            {
            case LadeskabState.Available:
                // Check for ladeforbindelse
                if (_charger.Connected())
                {
                    _door.LockDoor();
                    _charger.StartCharge();
                    _oldId = e.Id;
                    _logfile.LogDoorLocked(e.Id);


                    _display.ShowInstruction("Skabet er låst og din telefon lades. Brug dit RFID tag til at låse op.");
                    _state = LadeskabState.Locked;
                }
                else
                {
                    _display.ShowInstruction("Din telefon er ikke ordentlig tilsluttet. Prøv igen.");
                }

                break;

            case LadeskabState.DoorOpen:
                // Ignore
                break;

            case LadeskabState.Locked:
                // Check for correct ID
                if (e.Id == _oldId)
                {
                    _charger.StopCharge();
                    _door.UnlockDoor();
                    _logfile.LogDoorUnlocked(e.Id);

                    _display.ShowInstruction("Tag din telefon ud af skabet og luk døren");
                    _state = LadeskabState.Available;
                }
                else
                {
                    _display.ShowInstruction("Forkert RFID tag");
                }

                break;
            }
        }