예제 #1
0
        static void Main(string[] args)
        {
            // Assemble your system here from all the classes
            IRfidReader     rfidReader     = new RfidReader();
            IDoor           door           = new DoorSimulator();
            IUsbCharger     usbCharger     = new UsbChargerSimulator();
            IDisplay        display        = new DisplaySimulator();
            ILog            logger         = new FileLogger();
            IChargeControl  chargeControl  = new ChargeControl(usbCharger, display);
            IStationControl stationControl = new StationControl(chargeControl, door, display, rfidReader, logger);

            bool finish = false;

            do
            {
                string input;
                System.Console.WriteLine("Indtast E, O, C, F, A, R: ");
                input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    continue;
                }

                switch (input[0])
                {
                case 'E':
                    finish = true;
                    break;

                case 'O':
                    door.Open();
                    break;

                case 'C':
                    door.Close();
                    break;

                case 'F':
                    chargeControl.ConnectDevice();
                    break;

                case 'A':
                    chargeControl.DisconnectDevice();
                    break;

                case 'R':
                    System.Console.WriteLine("Indtast RFID id: ");
                    string idString = System.Console.ReadLine();

                    int id = Convert.ToInt32(idString);
                    rfidReader.OnRfidRead(id);
                    break;

                default:
                    break;
                }
            } while (!finish);
        }
예제 #2
0
		public void TestRfidDetectedEvent(int id)
		{
			
			int arg = -1;
			_uut.RfidDetected += (o, args) =>
			{
				arg = args.Id;
			};
			_uut.OnRfidRead(id);
			Assert.AreEqual(arg, id);
		}
예제 #3
0
        static void Main(string[] args)
        {
            ConsoleWriter       writer        = new ConsoleWriter();
            Display             display       = new Display(writer);
            TimeProvider        time          = new TimeProvider();
            FileWriter          file          = new FileWriter();
            LogFile             logfile       = new LogFile(file, time);
            RfidReader          rfid          = new RfidReader();
            Door                door          = new Door();
            UsbChargerSimulator usbCharger    = new UsbChargerSimulator();
            ChargeControl       chargeControl = new ChargeControl(display, usbCharger);
            StationControl      station       = new StationControl(chargeControl, door, rfid, display, logfile);

            bool finish = false;

            do
            {
                string input;
                System.Console.WriteLine("Indtast E, O, C, R: ");
                input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    continue;
                }

                switch (input[0])
                {
                case 'E':
                    finish = true;
                    break;

                case 'O':
                    door.OnDoorOpen();
                    break;

                case 'C':
                    door.OnDoorClose();
                    break;

                case 'R':
                    System.Console.WriteLine("Indtast RFID id: ");
                    string idString = System.Console.ReadLine();

                    int id = Convert.ToInt32(idString);
                    rfid.OnRfidRead(id);
                    break;

                default:
                    break;
                }
            } while (!finish);
        }
예제 #4
0
        static void Main(string[] args)
        {
            // Assemble your system here from all the classes
            Door           door       = new Door();
            RfidReader     rfidReader = new RfidReader();
            ChargeControl  charger    = new ChargeControl(new UsbChargerSimulator(), new DisplayConsole());
            DisplayConsole display    = new DisplayConsole();

            StationControl statCtrl = new StationControl(charger, display, door, rfidReader);


            bool finish = false;

            do
            {
                string input;
                System.Console.WriteLine("Indtast E, O, C, R: ");
                input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    continue;
                }

                switch (input[0])
                {
                case 'E':
                    finish = true;
                    break;

                case 'O':
                    door.OnDoorOpened();
                    break;

                case 'C':
                    door.OnDoorClosed();
                    break;

                case 'R':
                    System.Console.WriteLine("Indtast RFID id: ");
                    string idString = System.Console.ReadLine();

                    int id = Convert.ToInt32(idString);
                    rfidReader.OnRfidRead(id);
                    break;

                default:
                    break;
                }
            } while (!finish);
        }
예제 #5
0
        public void RfidReader_OnRfidRead_setIdTo123_EventRaisedWithArgs123()
        {
            //arrange
            int id      = 123;
            int eventId = 0;

            _uut.RfidDetectedEvent += (sender, args) => eventId = args;

            //act
            _uut.OnRfidRead(123);

            //assert
            Assert.That(eventId, Is.EqualTo(id));
        }
예제 #6
0
        public void RfidStatus_StatusSetToTrue_EventRaised()
        {
            _uut.OnRfidRead(1);

            Assert.That(_receivedRfidEventArgs, Is.Not.Null);
        }
 public void RfidRead_EventFired()
 {
     _uut.OnRfidRead(10);
     Assert.That(_receivedEventArgs, Is.Not.Null);
 }