Esempio n. 1
0
        static void Main(string[] args)
        {
            OptionManager optionMgr = new OptionManager();

            try
            {
                optionMgr.ComputeOptions(args);

                if (optionMgr._connectionString == null)
                {
                    throw new OptionException(OptionManager._connectionStringArgumentName +
                                              " argument is required!",
                                              OptionManager._connectionStringArgumentName);
                }
            }
            catch (OptionException e)
            {
                Console.Write("DMValidator: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Showing help prompt...");
                Console.WriteLine();
                optionMgr.ShowHelp();
            }

            TestCaseRunner runner = new TestCaseRunner(optionMgr._logPath, optionMgr._connectionString);

            //Get list of devices from IoT Hub
            runner.GetDevices();

            //If user just needs to list the devices, do that and quit.
            if (optionMgr._list)
            {
                foreach (string deviceId in runner._devicesToTest)
                {
                    Console.WriteLine(deviceId);
                }
                System.Environment.Exit(0);
            }

            //If user provided devices he wants to test, parse them and filter to only leave those devices
            if (optionMgr._devices != null)
            {
                runner.FilterDevices(optionMgr._devices);
                ReportUnusedDevices(optionMgr._devices, runner._devicesToTest);
            }

            //Get list of the JSON files
            runner.LoadScenarios(optionMgr._scenarios);

            //Run tests. Report to console.

            runner.ExecuteTestCases();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            OptionManager optionMgr = new OptionManager();

            try
            {
                optionMgr.ComputeOptions(args);

                if (optionMgr._connectionString == null)
                {
                    throw new OptionException(OptionManager._connectionStringArgumentName +
                                              " argument is required!",
                                              OptionManager._connectionStringArgumentName);
                }

                // Initialize the log...
                _logger = new Logger();
                _logger.TargetLogPath = optionMgr._logPath;
                _logger.CreateNewFile();
                _logger.Log(LogLevel.Information, "Log file is: " + _logger.GetLogFileName());

                // Initialize cloud service access...
                CloudServices cloudServices = new CloudServices(optionMgr._connectionString, optionMgr._storageConnectionString);

                // Initialize the test running...
                TestCaseRunner runner = new TestCaseRunner(
                    _logger,
                    cloudServices);

                // Set target devices...
                runner.DevicesToTest = GetTestDevicesList(optionMgr, cloudServices);

                // Set target tests
                runner.LoadFolderScenarios(optionMgr._scenariosFolder);
                runner.LoadFileScenarios(optionMgr._scenarioFiles);

                // Run the tests...
                runner.Execute();

                Environment.Exit(0);
            }
            catch (OptionException e)
            {
                Console.Write("DMValidator: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Showing help prompt...");
                Console.WriteLine();
                optionMgr.ShowHelp();

                Environment.Exit(-1);
            }
            catch (Exception e)
            {
                if (_logger != null)
                {
                    _logger.Log(LogLevel.Error, e.Message);
                }
                else
                {
                    Console.WriteLine("Error", e.Message);
                }

                Environment.Exit(-1);
            }
        }