public void DoorOpenedValidState_CorrectStateChange(DoorControlState initialState, DoorControlState expectedState)
        {
            _state.State = initialState;
            _UUT.DoorOpened();

            Assert.That(_state.State, Is.EqualTo(expectedState));
        }
        public void DoorOpenedValidState_DoorCloseCalled(DoorControlState state)
        {
            _state.State = state;
            _UUT.DoorOpened();

            _door.Received(1).Close();
        }
示例#3
0
 public DoorControl(IDoor door, IUserValidation UV, IEntryNotification EN, IAlarm alarm)
 {
     _door           = door;
     _userValidation = UV;
     _entry          = EN;
     _alarm          = alarm;
     _state          = DoorControlState.Closed;
 }
示例#4
0
        public DoorControl(IAlarm alarm, IDoor door, IEntryNotification entryNotification, IUserValidation userValidation)
        {
            _alarm             = alarm;
            _door              = door;
            _entryNotification = entryNotification;
            _userValidation    = userValidation;

            _controlState = DoorControlState.DoorClosed;
        }
示例#5
0
        public void DoorOpen()
        {
            switch (_controlState)
            {
            case DoorControlState.Validated:
                _controlState = DoorControlState.DoorOpened;
                break;

            default:
                _controlState = DoorControlState.DoorBreached;
                _alarm.RaiseAlarm();
                break;
            }
        }
        public void DoorOpenedValidState_RaiseAlarmCalled(DoorControlState state, bool RaiseAlarmExpected)
        {
            _state.State = state;
            _UUT.DoorOpened();

            if (RaiseAlarmExpected)
            {
                _alarm.Received(1).RaiseAlarm();
            }
            else
            {
                _alarm.DidNotReceive().RaiseAlarm();
            }
        }
示例#7
0
        public void DoorClosed()
        {
            switch (_controlState)
            {
            case DoorControlState.Validating:
                _controlState = DoorControlState.DoorClosed;
                break;

            case DoorControlState.Validated:
                _controlState = DoorControlState.DoorClosed;
                break;

            case DoorControlState.DoorOpened:
                _controlState = DoorControlState.DoorClosed;
                break;
            }
        }
示例#8
0
 public void RequestEntry(int id)
 {
     switch (_controlState)
     {
     case DoorControlState.DoorClosed:
         _controlState = DoorControlState.Validating;
         bool isValidId = _userValidation.ValidateEntryRequest(id);
         if (isValidId)
         {
             _controlState = DoorControlState.Validated;
             _entryNotification.NotifyEntryGranted();
             _door.Open();
         }
         else
         {
             _controlState = DoorControlState.DoorClosed;
             _entryNotification.NotifyEntryDenied();
         }
         break;
     }
 }
示例#9
0
        public void Hej()
        {
            var id = "";

            switch (_state)
            {
            case DoorControlState.Closed:
                if (RequestEntry(id))
                {
                    _door.Open();
                    _entry.NotifyEntryGranted();
                    _state = DoorControlState.Opening;
                }
                if (RequestEntry(id) == false)
                {
                    _entry.NotifyEntryDenied();
                    _state = DoorControlState.Closed;
                }
                else if (RequestEntry(id) == false && DoorOpen)
                {
                    _door.Close();
                    _alarm.SignalAlarm();
                }
                break;

            case DoorControlState.Opening:
                DoorOpened();
                //_door.Close();
                _state = DoorControlState.Closing;
                break;

            case DoorControlState.Closing:
                _door.Close();
                DoorClosed();
                _state = DoorControlState.Closed;
                break;
            }
        }
        public void RequestEntryEntryStateChanged_StateDoorClosed(int id, DoorControlState state)
        {
            _UUT.RequestEntry(id);

            Assert.That(_state.State, Is.EqualTo(state));
        }
 public void DoorClosedThrowsArgumentException_StateDoorNotClosing(DoorControlState state)
 {
     _state.State = state;
     Assert.Throws <ArgumentException>(() => _UUT.DoorClosed());
 }
 public void RequestEntryThrowsException_StateDoorNotClosed(int id, DoorControlState state)
 {
     _state.State = state;
     Assert.Throws <ArgumentException>(() => _UUT.RequestEntry(id));
 }