Пример #1
0
        public StationControl(IDoorSensor doorSensor, IUserOutput userOutput, IRfidReader rfidReader,
                              IChargeControl chargeControl, ILogger logger, IVerificationUnit verificationUnit)
        {
            //init states
            VACANT_DOOR_CLOSED_NO_PHONE_CONNECTED            = new States.VacantDoorClosedNoPhoneConnected(this);
            VACANT_DOOR_OPEN_NO_PHONE_CONNECTED              = new States.VacantDoorOpenNoPhoneConnected(this);
            VACANT_DOOR_OPEN_PHONE_CONNECTED                 = new States.VacantDoorOpenPhoneConnected(this);
            VACANT_DOOR_CLOSED_PHONE_CONNECTED_AWAITING_RFID = new States.VacantDoorClosedPhoneConnectedAwaitingRFID(this);
            OCCUPIED_DOOR_CLOSED_AWAITING_RFID               = new States.OccupiedDoorClosedAwaitingRFID(this);



            //init properties
            DoorSensor       = doorSensor;
            UserOutput       = userOutput;
            RfidReader       = rfidReader;
            ChargeControl    = chargeControl;
            Logger           = logger;
            VerificationUnit = verificationUnit;


            //Attaching events
            DoorSensor.DoorOpened           += DoorOpenedHandler;
            DoorSensor.DoorClosed           += DoorClosedHandler;
            RfidReader.RfidDetected         += RfidDetectedHandler;
            ChargeControl.PhoneConnected    += PhoneConnectedHandler;
            ChargeControl.PhoneDisconnected += PhoneDisconnectedHandler;


            //Initial state
            SetState(VACANT_DOOR_CLOSED_NO_PHONE_CONNECTED);
        }
        public void Setup()
        {
            _doorSensor       = Substitute.For <IDoorSensor>();
            _userOutput       = Substitute.For <IUserOutput>();
            _rfidReader       = Substitute.For <IRfidReader>();
            _chargeControl    = Substitute.For <IChargeControl>();
            _usbCharger       = Substitute.For <IUSBCharger>();
            _logger           = Substitute.For <ILogger>();
            _verificationUnit = Substitute.For <IVerificationUnit>();

            _uut = new StationControl(_doorSensor, _userOutput, _rfidReader, _chargeControl, _logger, _verificationUnit);
        }