static void Main(string[] args)
        {
            Console.WriteLine("Transportation Demo- Simulated Gate/Reader. Ctrl-C to exit.\n");

            // setup the items used by the simulated device
            TransportationDeviceClient myClient    = new TransportationDeviceClient(ConfigurationHandler.getConfig("AppSettings", "IoTConnectionString"));
            EventScheduler             myScheduler = new EventScheduler();

            // get device configuration details from JSON file
            GateReaderDeviceConfig deviceConfig = JsonConvert.DeserializeObject <GateReaderDeviceConfig>(ConfigurationHandler.GetDeviceRuntimeSettings("deviceConfig"));

            // create our simulated device
            myGateReader = new GateReaderDevice(deviceConfig, myClient, myScheduler);
            // initialize the device, setting up initial connections
            myGateReader.InitializeAsync().Wait();

            // start the device running
            myGateReader.StartAllEvents();

            // put the host into a loop
            while (true)
            {
                //do stuff
                Thread.Sleep(30000);
            }

            myGateReader.StopAllEvents();

            Console.ReadLine();
        }
        public void SetUp()
        {
            deviceconfig = new GateReaderDeviceConfig()
            {
                DeviceId   = "myFakeDevice",
                DeviceType = DeviceType.GateReader
            };

            // create a fake device twin
            // set up device propeties
            JObject myDesiredProperties = new JObject();

            // set reported properties
            myDesiredProperties.Add("status", DeviceStatus.enabled.ToString());

            fakeTwin = new Microsoft.Azure.Devices.Shared.Twin(deviceconfig.DeviceId);
            fakeTwin.Properties.Desired = new TwinCollection(myDesiredProperties, null);
        }
        // test initialization
        public GateReaderTest()
        {
            deviceconfig = new GateReaderDeviceConfig()
            {
                DeviceId          = "myFakeDevice",
                DeviceType        = DeviceType.GateReader,
                Status            = "enabled",
                initialDirection  = "In",
                PercentOfWrongWay = 0
            };

            // create a fake device twin
            // set up device propeties
            JObject myReportedProperties = new JObject();

            // set reported properties
            myReportedProperties.Add("GateDirection", "Out");
            myReportedProperties.Add("status", deviceconfig.Status); // need to match so status update doesn't clobber the twin

            fakeTwin = new Microsoft.Azure.Devices.Shared.Twin(deviceconfig.DeviceId);
            fakeTwin.Properties.Reported = new TwinCollection(myReportedProperties, null);
        }
 /// <summary>
 /// Device class constructor, calls base constructor and starts loading device values.
 /// Accepts a device config, client, and event scheduler. The later 2 are externalized to make
 /// unit testing of the device easier.
 /// </summary>
 public GateReaderDevice(GateReaderDeviceConfig deviceConfig, IDeviceClient client, IEventScheduler eventScheduler)
     : base(deviceConfig, client, eventScheduler)
 {
     // save device configuration
     this.deviceConfig = deviceConfig;
 }