public CommandManager(string path, bool isDirectory, IEmailHelper emailHelper, IImpersonateUser impersonateUser, IScreenRecorderHelper screenRecorderHelper, OnCommandManagerInitComplete onCommandManagerInitComplete, string testExtFilter = "*.tst") { _emailHelper = emailHelper; _impersonateUser = impersonateUser; _screenRecorderHelper = screenRecorderHelper; TestObjectDTO = new List <TestObjectDTO>(); if (isDirectory) { if (Directory.Exists(path)) { var files = Directory.GetFiles(path, testExtFilter); if (files.Length == 0) { onCommandManagerInitComplete(ResponseStatus.Failed, "The directory must contain sub-directories with tests inside!"); } else { onCommandManagerInitComplete(ResponseStatus.Success, "Success"); foreach (var item in files) { var testObjectDTO = _parseTestFile(item); TestObjectDTO.Add(testObjectDTO); } } } else { throw new Exception(path + " folder doesnot exist!");; } } else { if (File.Exists(path)) { var fi = new FileInfo(path); if (fi.Extension.ToLower() == testExtFilter.Replace("*", "")) { onCommandManagerInitComplete(ResponseStatus.Success, "Success"); var testObjectDTO = _parseTestFile(path); TestObjectDTO.Add(testObjectDTO); } else { throw new Exception(path + " is not a valid test file, it must have a .tst extension!"); } } else { throw new Exception(path + " file doesnot exist!"); } } }
static void Main(string[] arguments) { // arguments = new string[1] { @"C:\Dev\mrpAutomationTests" }; if (arguments.Count() > 0) { NativeMethods.AllocConsole(); int port = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["EmailPortNumber"]); string smtp = System.Configuration.ConfigurationManager.AppSettings["EmailSMTP"]; _emailHelper = new EmailHelper(smtp, port); _impersonateUser = new ImpersonateUser(); string folderPath = arguments[0]; Console.WriteLine("******************Infinity.Automation Tester v1.0.0*******************"); Console.WriteLine("Started :" + DateTime.Now); Console.WriteLine("Checking tests in directory :" + folderPath + "...please wait..."); Console.WriteLine(""); MinimizeConsoleWindow(); string path = folderPath; string previousDirPath = ""; var directories = Directory.GetDirectories(path); foreach (var dir in directories) { string dirPath = dir; if (previousDirPath != dirPath) { previousDirPath = dirPath; DirectoryInfo di = new DirectoryInfo(dirPath); Console.WriteLine("Running tests in sub-directory :" + di.Name + "...please wait..."); screenRecorderHelper = new ScreenRecorderHelper(); _commandManager = new CommandManager(dirPath, true, _emailHelper, _impersonateUser, screenRecorderHelper, _onCommandManagerInitComplete); _commandManager.ExecuteCommands(_commandManager.TestObjectDTO, _onTestRunComplete, _onTestCommandComplete, _onAllTestRunComplete); } } Console.ReadLine(); } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } }
static void Main(string[] arguments) { // arguments = new string[1] { @"C:\Dev\mrpAutomationTests" }; if (arguments.Count() > 0) { NativeMethods.AllocConsole(); if(arguments.Count() > 1) { _isDebugInfo = arguments[1].ToString().ToLower()=="true" || arguments[1].ToString().ToLower() == "1" ? true : false; try { _isAutoClose= arguments[2].ToString().ToLower() == "true" || arguments[2].ToString().ToLower() == "1" ? true : false; } catch { } } int port = System.Configuration.ConfigurationManager.AppSettings["EmailPortNumber"].ToString() == "" ? 0 : Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["EmailPortNumber"]); string smtp = System.Configuration.ConfigurationManager.AppSettings["EmailSMTP"]; _emailHelper = new EmailHelper(smtp, port); _impersonateUser = new ImpersonateUser(); string folderPath = arguments[0]; Console.WriteLine("******************Infinity.Automation Tester v1.0.0*******************"); Console.WriteLine("Started :" + DateTime.Now); Console.WriteLine("Checking tests in directory :" + folderPath + "...please wait..."); Console.WriteLine(""); MinimizeConsoleWindow(); string path = folderPath; string previousDirPath = ""; var directories = Directory.GetDirectories(path); var responses = new List<TestResponseDTO>(); var dirToUse = new List<string>(); foreach (var dir in directories) { if (new DirectoryInfo(dir).Name.ToLower().StartsWith("results_")) { continue; } dirToUse.Add(dir); } if (dirToUse.Count == 0) { dirToUse = new List<string>(); dirToUse.Add(path); } IPortableDataStore portableDataStore = new PortableDataStore(); var portableDBPath = System.Configuration.ConfigurationManager.AppSettings["PortableDB"].ToString(); if (portableDBPath.StartsWith("\\")) { portableDBPath = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName + portableDBPath; } portableDataStore.DBFullPath = portableDBPath; portableDataStore.EnablePortablDB = System.Configuration.ConfigurationManager.AppSettings["EnablePortableDB"].ToString().ToLower()=="true"; foreach (var dir in dirToUse) { string dirPath = dir; if (previousDirPath != dirPath) { previousDirPath = dirPath; DirectoryInfo di = new DirectoryInfo(dirPath); Console.WriteLine("Running tests in sub-directory :" + di.Name + "...please wait..."); //screenRecorderHelper = new ScreenRecorderHelper(); screenRecorderHelper = new ScreenRecorderHelperNew(); string showMessagePrefix = System.Configuration.ConfigurationManager.AppSettings["ShowMessageTestRunningPrefix"].ToString(); _commandManager = new CommandManager(dirPath, true, _emailHelper, _impersonateUser, screenRecorderHelper, _onCommandManagerInitComplete,"*.tst", _isDebugInfo, showMessagePrefix, portableDataStore); responses =(_commandManager.ExecuteCommands(_commandManager.TestObjectDTO, _onTestRunComplete, _onTestCommandComplete, _onAllTestRunComplete, _onTestRunStarted)); if (!_isDebugInfo) { Console.WriteLine("Test completed :" + DateTime.Now); } _commandManager.CreateFinalOutputOfResults(responses); _onAllTestRunComplete(responses); } } if (!_isAutoClose) { Console.ReadLine(); } } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } }