コード例 #1
0
        // 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;
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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);
コード例 #5
0
        public void SetUp()
        {
            _recievedRfidDetectedEventArgs = null;

            _uut = new RfidReaderSimulator();
            _uut.RFIDDetectedEvent += (o, args) =>
            {
                _recievedRfidDetectedEventArgs = args;
            };
        }
コード例 #6
0
 public void OnRFIDDetected_ReadRFIDIDid_EventRFIDValueEqualsid(int id)
 {
     _uut.RFIDDetectedEvent += (o, args) => { _receivedArgs = args; };
     _uut.ReadRFID(id);
     Assert.That(_receivedArgs.RFID, Is.EqualTo(id));
 }
コード例 #7
0
 private void HandleRfidDetectedEvent(object sender, RFIDDetectedEventArgs e)
 {
     RfidDetected(e.Id);
 }
コード例 #8
0
ファイル: StationControl.cs プロジェクト: Tueaj/LadeStation
 private void  RFidDetectedEvent(object sender, RFIDDetectedEventArgs e)
 {
     RfidDetected(e.RFID);
 }