Пример #1
0
        public void Rfid_AvailableState_NoConnection(int id)
        {
            RfidEventArgs RfidArgs = new RfidEventArgs(id);

            _chargeControl.connection_establishment().Returns(false);
            _rfidreader.RfidHandler += Raise.EventWith(RfidArgs);

            _door.DidNotReceive().Lock();
            _chargeControl.DidNotReceive().charge_control_start();
            _disp.Received().PrintStationMsg(_NoConnectionMsg);
        }
        public void CheckIf_BehaviorIsRight_WhenLadeskabStateIsAvailable_AndChargerIsNotConnected()
        {
            int rfidDetected = 123;

            _chargeControl.IsConnected().Returns(false);

            _rfidReaderSimulator.RFIDDetectedEvent +=
                Raise.EventWith(new RFIDDetectedEventArgs()
            {
                RFIDDetected = rfidDetected
            });

            _doorSimulator.DidNotReceive().LockDoor();
            _chargeControl.DidNotReceive().StartCharge();
            _logFileSimulator.DidNotReceive().LogDoorLocked(rfidDetected);
            _displaySimulator.Received(1).ShowConnectionErrorMessage();
        }
Пример #3
0
        public void RaisedDoorChangeEvent_Available_IsConnected_isFalse_StartCharge_NotCalled(bool doorstatus, bool rfidstatus, bool isConnected)
        {
            //Ønsker at gøre state = available
            _door.DoorChangedEvents += Raise.EventWith(new DoorChangedEventArgs()
            {
                DoorStatus = doorstatus
            });

            _chargeControl.IsConnected().Returns(isConnected);

            //Problem: Rfidstatus spiller ingen rolle i koden??
            _rfidReader.RfidSensedEvents += Raise.EventWith(new RfidSensedEventArgs()
            {
                RfidSensed = rfidstatus, Id = 10
            });

            _chargeControl.DidNotReceive().StartCharge();
        }
Пример #4
0
        public void RfidDetected_Available_ChargerNotConnected()
        {
            //Act + Arrange
            _chargeControl.IsConnected().Returns(false);
            const int id = 5;

            _reader.RfidEvent += Raise.EventWith(new RfidEventArgs()
            {
                Id = id
            });

            //Assert
            Assert.Multiple(() =>
            {
                _door.DidNotReceive().LockDoor();
                _chargeControl.DidNotReceive().StartCharge();
                _log.DidNotReceive().LogDoorLocked(id);
                _display.Received().ShowMessage("Din telefon er ikke ordentlig tilsluttet. Prøv igen.");
            });
        }
Пример #5
0
        public void InitialRfid_DoorOpened()
        {
            _iDoor.DoorOpenEvent += Raise.EventWith(new DoorOpenChangedEventArgs());
            var id = 12;

            _iReader.TagDataEvent += Raise.EventWith(new ReadtagChangedEventArgs()
            {
                Tag = id
            });
            _iDoor.DidNotReceive().LockDoor();
            _iDisplay.DidNotReceive().DisplayMessage("Døren er låst");
            _iChargeControl.DidNotReceive().Regulate();
        }
        public void SwitchCaseLocked_IdIsNotEqualToOldId_StopChargeIsActivatedIsFalse()
        {
            //arrange
            chargeControl.IsConnected().Returns(true);

            //act
            rfidReader.RfidReaderEvent += Raise.EventWith(new RfidDetectedEventArgs {
                Id = 1200
            });
            rfidReader.RfidReaderEvent += Raise.EventWith(new RfidDetectedEventArgs {
                Id = 1000
            });

            //assert
            chargeControl.DidNotReceive().StopCharge();
        }
Пример #7
0
        public void StopCharge_WhenPhoneLockerIsLockedRfidDetected_RFIDIsWrong_CallNotReceived(int rfid)
        {
            //ARRANGE
            UUT.State = PhoneLockerState.Locked;

            UUT.Rfid  = rfid; //forkert id fra event
            UUT.oldId = 99;   //korrekt id fra vedkommende der låste skabet

            //ACT
            fakeRfidReader.RFIDDetectedEvent += Raise.EventWith(new RFIDDetectedEventArgs()
            {
                RFID = 0
            });

            //ASSERT
            fakeChargeControl.DidNotReceive().StopCharge();
        }
Пример #8
0
 public void HandleDoorStateChangedLockedTest()
 {
     _chargeControl.IsConnected().Returns(true);
     _RFIDReader.RFIDReadEvent += Raise.EventWith <RFIDReadEventArgs>(new RFIDReadEventArgs()
     {
     });
     _chargeControl.ClearReceivedCalls();
     _RFIDReader.ClearReceivedCalls();
     _door.DoorStateChangedEvent += Raise.EventWith <DoorStateEventArgs>(new DoorStateEventArgs()
     {
         Open = true
     });
     _door.DidNotReceive();
     _chargeControl.DidNotReceive();
     _display.DidNotReceive();
     _logfile.DidNotReceive();
     _RFIDReader.DidNotReceive();
 }
        public void UnlockDoor_CheckCorrectID_Wrong()
        {
            int oldId = 3;
            int newId = 5;

            _chargeControl.IsConnected().Returns(true);
            _rfidReader.RFIDChangedEvent += Raise.EventWith(new RFIEDEventArgs {
                RFID = oldId
            });

            _rfidReader.RFIDChangedEvent += Raise.EventWith(new RFIEDEventArgs {
                RFID = newId
            });

            _logFile.DidNotReceive().LogDoorUnlocked(newId);
            _chargeControl.DidNotReceive().StopCharge();
            _door.DidNotReceive().UnlockDoor();

            _display.Received(1).Print("Forkert RFID tag");
        }