// Eksempel på event handler for eventet "RFID Detected" fra tilstandsdiagrammet for klassen private void RfidDetected(object sender, RFIDDetectedEventArgs e) { switch (_state) { case LadeskabState.Available: // Check for ladeforbindelse if (_charger.IsConnected()) { _door.LockDoor(); _charger.StartCharge(); _oldId = e.RFIDDetected; _logFileSimulator.LogDoorLocked(e.RFIDDetected); _displaySimulator.ShowPhoneChargingMessage(); _state = LadeskabState.Locked; } else { _displaySimulator.ShowConnectionErrorMessage(); } break; case LadeskabState.DoorOpen: // Ignore break; case LadeskabState.Locked: // Check for correct ID CheckId(_oldId, e.RFIDDetected); break; } }
public void ChargerEvent_ChargeIsConnectedTrue_StartChargeCalledOnChargeControl() { //Arrange ChargerConnectionValue args0 = new ChargerConnectionValue { ChargerConnected = true }; _chargeControlSource.ChargerConnectionValueEvent += Raise.EventWith(args0); DoorValueEventArgs args1 = new DoorValueEventArgs { DoorOpen = false }; _doorSource.DoorValueEvent += Raise.EventWith(args1); RFIDDetectedEventArgs args2 = new RFIDDetectedEventArgs { RFID = 54321 }; _RfidReader.RFIDDetectedEvent += Raise.EventWith(args2); //Act //Assert _chargeControlSource.Received().StartCharge(); }
public void ChargerEvent_ChargeIsConnectedFalse_PrintConnectionFailCalledOnDisplay() { //Arrange ChargerConnectionValue args0 = new ChargerConnectionValue { ChargerConnected = false }; _chargeControlSource.ChargerConnectionValueEvent += Raise.EventWith(args0); DoorValueEventArgs args1 = new DoorValueEventArgs { DoorOpen = false }; _doorSource.DoorValueEvent += Raise.EventWith(args1); RFIDDetectedEventArgs args2 = new RFIDDetectedEventArgs { RFID = 54321 }; _RfidReader.RFIDDetectedEvent += Raise.EventWith(args2); //Act //Assert _display.Received().PrintConnectionFail(); }
public void ChargerEvent_ChargeIsConnectedTrue_LogDoorLockedCalledOnLogfile() { //Arrange ChargerConnectionValue args0 = new ChargerConnectionValue { ChargerConnected = true }; _chargeControlSource.ChargerConnectionValueEvent += Raise.EventWith(args0); DoorValueEventArgs args1 = new DoorValueEventArgs { DoorOpen = false }; _doorSource.DoorValueEvent += Raise.EventWith(args1); RFIDDetectedEventArgs args2 = new RFIDDetectedEventArgs { RFID = 54321 }; _RfidReader.RFIDDetectedEvent += Raise.EventWith(args2); //Act //Assert _logFile.ReceivedWithAnyArgs().LogDoorLocked(default);
public void SetUp() { _recievedRfidDetectedEventArgs = null; _uut = new RfidReaderSimulator(); _uut.RFIDDetectedEvent += (o, args) => { _recievedRfidDetectedEventArgs = args; }; }
public void OnRFIDDetected_ReadRFIDIDid_EventRFIDValueEqualsid(int id) { _uut.RFIDDetectedEvent += (o, args) => { _receivedArgs = args; }; _uut.ReadRFID(id); Assert.That(_receivedArgs.RFID, Is.EqualTo(id)); }
private void HandleRfidDetectedEvent(object sender, RFIDDetectedEventArgs e) { RfidDetected(e.Id); }
private void RFidDetectedEvent(object sender, RFIDDetectedEventArgs e) { RfidDetected(e.RFID); }