Esempio n. 1
0
        public void RfidDetected_chargingNotConnectedÉlse_DoorNotLocked()
        {
            //Arrange
            _usbCharger    = Substitute.For <IUsbCharger>();
            _door          = Substitute.For <IDoor>();
            _chargeControl = new ChargeControl(_usbCharger, _display);


            _usbCharger.Connected.Returns(false);



            uut.RfidDetected(100);

            _door.DidNotReceive().LockDoor();
        }
Esempio n. 2
0
        public void RfidDetected_DoorOpen_isCorrect()
        {
            // Arrange
            var uut = new StationControl(new Door(), new RFIDReader(), new UsbChargerSimulator(), new Display());

            // Act
            uut._state = StationControl.LadeskabState.DoorOpen;
            uut.RfidDetected(1);

            // Assert
            // Doesn't do anything, state doesn't change
            Assert.That(uut._state == StationControl.LadeskabState.DoorOpen);
        }
Esempio n. 3
0
        public void RfidDetected_Locked_StopCharge_isCalled()
        {
            // Arrange
            IUsbCharger fakeCharger = Substitute.For <IUsbCharger>();

            fakeCharger.Connected.Returns(true);

            var uut = new StationControl(new Door(), new RFIDReader(), fakeCharger, new Display());

            // Act
            uut._state = StationControl.LadeskabState.Available;
            uut.RfidDetected(1);

            // State is "locked" with _oldId = 1
            Assert.That(uut._state == StationControl.LadeskabState.Locked);

            // Calling with same id, calling StopCharge
            uut.RfidDetected(1);

            // Assert
            fakeCharger.Received().StopCharge();
        }
Esempio n. 4
0
        public void RfidDetected_Locked_idIsNotOldId_isCorrect()
        {
            // Arrange
            IUsbCharger fakeCharger = Substitute.For <IUsbCharger>();

            fakeCharger.Connected.Returns(true);

            var uut = new StationControl(new Door(), new RFIDReader(), fakeCharger, new Display());

            // Act
            uut._state = StationControl.LadeskabState.Available;
            uut.RfidDetected(1);

            // State is "locked" with _oldId = 1
            Assert.That(uut._state == StationControl.LadeskabState.Locked);

            // Calling with different id, stays locked and doesn't change state
            uut.RfidDetected(2);

            // Assert
            Assert.That(uut._state == StationControl.LadeskabState.Locked);
        }
Esempio n. 5
0
        public void RfidDetected_LadeskabeStateLockedAndIdEqualOldId_LadeskabeIsAvailable()
        {
            // Arrange
            _usbCharger    = Substitute.For <IUsbCharger>();
            _logfile       = Substitute.For <Logfile>();
            _chargeControl = new ChargeControl(_usbCharger, _display);
            int id = 100;

            StationControl uut = new StationControl(_rfidReader, _door, _display, _logfile, _chargeControl);

            //act
            uut._state = Ladeskab.StationControl.LadeskabState.Available;

            _usbCharger.Connected.Returns(true);

            uut.RfidDetected(id); //Sætter oldId = id

            uut.RfidDetected(id);

            //Assert
            Assert.That(uut._state, Is.EqualTo(Ladeskab.StationControl.LadeskabState.Available));
        }
Esempio n. 6
0
 public void RdidDetected_IsAvailable_IsConnected_LockDoorIsCalled()
 {
     // Clear subs
     _fakeDoor.ClearReceivedCalls();
     // Arrange
     _fakeChargeControl.Connected.Returns(true);
     _uut._state = StationControl.LadeskabState.Available;
     // Act
     _uut.RfidDetected(1);
     // Assert
     _fakeDoor.Received(1).LockDoor();
 }
Esempio n. 7
0
        public void RfidDetected_Locked_idIsOldId_isCorrect()
        {
            // Arrange
            IUsbCharger fakeCharger = Substitute.For <IUsbCharger>();

            fakeCharger.Connected.Returns(true);

            var uut = new StationControl(new Door(), new RFIDReader(), fakeCharger, new Display());

            // Act
            uut._state = StationControl.LadeskabState.Available;
            // Call with id = 1
            uut.RfidDetected(1);

            // State is "locked" with _oldId = 1
            Assert.That(uut._state == StationControl.LadeskabState.Locked);

            // Calling with same id, unlocking and changing state to available
            uut.RfidDetected(1);

            // Assert
            Assert.That(uut._state == StationControl.LadeskabState.Available);
        }
Esempio n. 8
0
        public void RfidDetected_Available_StartCharge_isCalled()
        {
            // Arrange
            IUsbCharger fakeCharger = Substitute.For <IUsbCharger>();

            fakeCharger.Connected.Returns(true);

            var uut = new StationControl(new Door(), new RFIDReader(), fakeCharger, new Display());

            // Act
            uut._state = StationControl.LadeskabState.Available;
            uut.RfidDetected(1);

            // Assert
            fakeCharger.Received().StartCharge();
        }
Esempio n. 9
0
        public void RfidDetected_Available_ConnectedFalse_isCorrect()
        {
            // Arrange
            IUsbCharger fakeCharger = Substitute.For <IUsbCharger>();

            fakeCharger.Connected.Returns(false);

            var uut = new StationControl(new Door(), new RFIDReader(), fakeCharger, new Display());

            // Act
            uut._state = StationControl.LadeskabState.Available;
            uut.RfidDetected(1);

            // Assert
            // State doesn't change if connected is false.
            Assert.That(uut._state == StationControl.LadeskabState.Available);
        }
Esempio n. 10
0
        public void RfidDetected_Available_ConnectedTrue_isCorrect()
        {
            // Arrange
            IUsbCharger fakeCharger = Substitute.For <IUsbCharger>();

            fakeCharger.Connected.Returns(true);

            var uut = new StationControl(new Door(), new RFIDReader(), fakeCharger, new Display());

            // Act
            uut._state = StationControl.LadeskabState.Available;
            uut.RfidDetected(1);

            // Assert
            // State changes to "locked" if the connected is true.
            Assert.That(uut._state == StationControl.LadeskabState.Locked);
        }
Esempio n. 11
0
        public void RfidDetected_LadeskabeStateisDoorOpen_LadeskabeIsDoorOpen()
        {
            // Arrange
            _usbCharger    = Substitute.For <IUsbCharger>();
            _logfile       = Substitute.For <Logfile>();
            _chargeControl = new ChargeControl(_usbCharger, _display);
            int id = 100;

            StationControl uut = new StationControl(_rfidReader, _door, _display, _logfile, _chargeControl);

            //act
            uut._state = Ladeskab.StationControl.LadeskabState.DoorOpen;

            _usbCharger.Connected.Returns(true);


            uut.RfidDetected(id);

            //Assert
            Assert.That(uut._state, Is.EqualTo(Ladeskab.StationControl.LadeskabState.DoorOpen));
        }