예제 #1
0
        public void OnConstructisdon_LenghtIsZero()
        {
            var testlogEntry = new ClosetLog
            {
                Date = DateTime.Now,
                Log  = "Test"
            };

            //Act
            _uut.Clear();

            Assert.That(File.Exists(_uut.Get()), Is.EqualTo(false));
        }
예제 #2
0
 public void Setup()
 {
     _uut = new ClosetLog();
 }
예제 #3
0
        // Eksempel på event handler for eventet "RFID Detected" fra tilstandsdiagrammet for klassen
        private void RfidDetected(int id)
        {
            switch (_state)
            {
            case LadeskabState.Available:
                // Check for ladeforbindelse
                if (_chargeControl.IsConnected())
                {
                    _door.LockDoor();
                    _chargeControl.StartCharge();
                    _oldId = id;

                    var logEntry = new ClosetLog
                    {
                        Date = DateTime.Now,
                        Log  = ": Skab låst med RFID: " + id.ToString()
                    };
                    _logger.Add(logEntry);

                    _state = LadeskabState.Locked;
                    _display.CurrentMessageId = DisplayMessageId.SlotTaken;
                    _display.UpdateDisplay();
                }
                else
                {
                    _display.CurrentMessageId = DisplayMessageId.ConnectionError;
                    _display.UpdateDisplay();
                }

                break;

            case LadeskabState.DoorOpen:

                break;

            case LadeskabState.Locked:
                // Check for correct ID
                if (id == _oldId)
                {
                    _chargeControl.StopCharge();
                    _door.UnlockDoor();

                    var logEntry = new ClosetLog
                    {
                        Date = DateTime.Now,
                        Log  = ": Skab låst op med RFID: " + id.ToString()
                    };
                    _logger.Add(logEntry);

                    _display.CurrentMessageId = DisplayMessageId.RemovePhone;
                    _display.UpdateDisplay();
                    _state = LadeskabState.Available;
                }
                else
                {
                    _display.CurrentMessageId = DisplayMessageId.RfidError;
                    _display.UpdateDisplay();
                }

                break;
            }
        }