static void Main(string[] args)
        {
            log("Welcome to pCloudy c# Sample Project");
            var    con       = new ssts.util.pCloudy.pCloudyClient("https://device.pcloudy.com");
            String authToken = con.authenticateUser(yourEmailId, yourApiKey);

            log("AuthToken: " + authToken);

            log("-------------------------------");


            var selectedDevices = con.chooseMultipleDevices(authToken, "android");

            log("Total Devices Booked: " + selectedDevices.Count);
            String sessionName = "AppiumNative-" + selectedDevices.First().display_name;

            if (selectedDevices.Count > 1)
            {
                sessionName += " and " + (selectedDevices.Count - 1) + " others";
            }


            log("-------------------------------");
            var bookedDevices = con.bookDevicesForAppium(authToken, selectedDevices, TimeSpan.FromMinutes(BOOKINGDURAITON), sessionName);

            log("Devices Booked....");
            log("-------------------------------");


            FileInfo fileToBeuploaded = new FileInfo(appPath);

            var alreadyUploadedApp = con.getApplicationIfUploaded(authToken, fileToBeuploaded.Name);

            if (alreadyUploadedApp == null)
            {
                Console.Out.WriteLine("Uploading App :  " + appPath);
                var uploadedApp = con.uploadApp(authToken, fileToBeuploaded,
                                                x =>
                {
                    log("Uploaded: " + x + "%");
                }
                                                );

                log("App uploaded...");
                alreadyUploadedApp      = new ssts.util.pCloudy.DTO.pDriveFileDTO();
                alreadyUploadedApp.file = uploadedApp.File;
            }
            else
            {
                log("App already present in Cloud Drive. Not uploading...");
            }
            con.initAppiumHubForApp(authToken, alreadyUploadedApp);
            var endpoint = con.getAppiumEndpoint(authToken);

            log("Appium Endpoint: " + endpoint);
            log("Result Folder Path: " + con.getAppiumReportFolder(authToken));


            List <Thread> threadPool = new List <Thread>();

            for (int i = 0; i < bookedDevices.Length; i++)
            {
                var    aDevice        = bookedDevices[i];
                String bookedDeviceID = aDevice.capabilities.deviceName;

                var capabilities = new DesiredCapabilities();

                capabilities.SetCapability("deviceName", bookedDeviceID);
                capabilities.SetCapability("platformName", "Android");
                capabilities.SetCapability("appActivity", "com.ba.mobile.LaunchActivity");
                capabilities.SetCapability("appPackage", "com.ba.mobile");

                PCloudyAppiumSession session = new PCloudyAppiumSession(con, authToken, aDevice);

                TestCase tc = new TestCase(endpoint, capabilities, session);

                var t = new Thread(new ThreadStart(tc.run));
                t.Start();
                threadPool.Add(t);
            }

            foreach (Thread t in threadPool)
            {
                t.Join();
            }

            log("Press any key to exit..");
            Console.In.ReadLine();
        }
        public static ITestDataSource[] init()
        {
            if (isRunningInTestDiagnosticMode())
            {
                return(pCloudyDeviceList());
            }
            else
            {
                log("Called init");
                var    pCloudySessions = new List <PCloudyAppiumSession>();
                var    con             = new ssts.util.pCloudy.pCloudyClient("https://device.pcloudy.com");
                String authToken       = con.authenticateUser("*****@*****.**", "3vngzzzghz267t5b2qqz3r5r");
                log("AuthToken: " + authToken);


                printDeviceFullNames(authToken, con);

                #region autoselectDevices
                //   log("maxDeviceCount:" + maxDeviceCount);
                //   var selectedDevices = con.getAvailableDevices(authToken, BOOKINGDURATION, "android", minimumVersion, maximumVersion, maxDeviceCount).ToList();
                #endregion

                var deviceFullNameArray = (from itm in pCloudyDeviceList() select itm.getDeviceName()).ToArray();
                var selectedDevices     = con.getAvailableDevicesByArrayOfFullNames(authToken, BOOKINGDURATION, "android", deviceFullNameArray).ToList();

                String sessionName = "NUnit Appium-" + System.DateTime.Now.ToString("u");

                FileInfo fileToBeuploaded = new FileInfo(appPath);

                var alreadyUploadedApp = con.getApplicationIfUploaded(authToken, fileToBeuploaded.Name);
                if (alreadyUploadedApp == null)
                {
                    Console.Out.WriteLine("Uploading App :  " + appPath);
                    var uploadedApp = con.uploadApp(authToken, fileToBeuploaded,
                                                    x =>
                    {
                        log("Uploaded: " + x + "%");
                    }
                                                    );

                    log("App uploaded...");
                    alreadyUploadedApp      = new ssts.util.pCloudy.DTO.pDriveFileDTO();
                    alreadyUploadedApp.file = uploadedApp.File;
                }

                log("-------------------------------");
                var bookedDevices = con.bookDevicesForAppium(authToken, selectedDevices, BOOKINGDURATION, sessionName);
                log("Total Devices Booked: " + bookedDevices.Count());
                log("-------------------------------");


                con.initAppiumHubForApp(authToken, alreadyUploadedApp);
                var endpoint = con.getAppiumEndpoint(authToken);
                log("Appium Endpoint: " + endpoint);
                log("Result Folder Path: " + con.getAppiumReportFolder(authToken));


                foreach (BookingDtoDevice itm in bookedDevices)
                {
                    PCloudyAppiumSession appiumSession = new PCloudyAppiumSession(con, authToken, itm);
                    pCloudySessions.Add(appiumSession);
                }


                return((from itm in pCloudySessions select new TestCaseDataSource(itm)).ToArray());
            }
        }