public void Unlocked_IdDetected_logCalled() { //setting up with placing the phone _chargerControl.IsConnected().Returns(true); _door.DoorStateChangedEvent += Raise.EventWith(new DoorStateChangedEventArgs { State = DoorState.Open }); _door.DoorStateChangedEvent += Raise.EventWith(new DoorStateChangedEventArgs { State = DoorState.Closed }); //Scanning an ID _idReader.RfIdDetectedEvent += Raise.EventWith(new RfIdEventArgs { Id = 123 }); _log.Received(1).LogDoorLocked(123); }
// Eksempel på event handler for eventet "RFID Detected" fra tilstandsdiagrammet for klassen private void RfidDetected(int id) { switch (_state) { case LadeskabState.Available: // Check for ladeforbindelse if (_chargeControl.IsConnected()) { _oldId = id; _state = LadeskabState.Locked; _chargeControl.StartCharge(); _log.LogDoorLocked(id); _display.DisplayMessage("Ladeskab optaget"); } else { _display.DisplayMessage("Tilslutningsfejl"); } break; case LadeskabState.DoorOpen: // Ignore break; case LadeskabState.Locked: // Check for correct ID if (id != _oldId) { _display.DisplayMessage("Forkert RFID"); } else { _chargeControl.StopCharge(); _state = LadeskabState.Available; _log.LogDoorUnlocked(id); _display.DisplayMessage("Fjern telefon"); } break; } }
public void HandleDoorOpenEvent_EventFired_DoorOpenState() { //Setup _chargerControl.IsConnected().Returns(false); _door.DoorOpenEvent += Raise.EventWith(new DoorEventArgs() { DoorOpen = true, DoorClosed = false }); //Assert Assert.That(uut.State == StationControl.LadeskabState.DoorOpen); }
public void IsConnected_IsTrue() { UsbCharger.Connected.Returns(true); Assert.IsTrue(_uut.IsConnected()); }