public static List <DataDriver> CheckDriver(long ID) { List <DataDriver> data = new List <DataDriver>(); using (SqlDataReader reader = SqlHelper.ExecuteReader(ConnectData.ConnectionString, "sp_CheckDriver", ID)) { if (reader.HasRows) { while (reader.Read()) { var d = new DataDriver(); d.DriverName = reader["DriverName"].ToString(); d.TuNgay = Convert.ToDateTime(reader["TuNgay"]); object DenNgay = reader["DenNgay"]; if (DenNgay == DBNull.Value) { d.DenNgay = DateTime.Now; } else { d.DenNgay = Convert.ToDateTime(reader["DenNgay"]); } d.TransmitTime = Convert.ToDateTime(reader["TransmitTime"]); data.Add(d); } return(data); } return(data); } }
public static string GenerateExpectedFilePath() { var expectedFileName = DataDriver.GetTestCaseDataValueByName(TestDataParameters.ExpectedResultsFileName.ToString()); var expectedFilesPath = DataDriver.GetConfigurationValueInSectionByName("GlobalSettings", "TestConfigurationSourcePath") + "\\ExpectedFiles"; return(expectedFilesPath + "\\" + expectedFileName); }
protected override void ExecuteTest() { GlobalReporter.CloseTestCase(); //Test date time change //TestDriver.Utilities_ShiftDateBy(0, 0, 5); //TestDriver.Utilities_ResetDate(); //DataDriver.OverrideEnvironmentValueForKey("BROWSER", Browser.Firefox.ToString()); var testSuiteName = DataDriver.GetTestCaseDataValueByName("TestSuiteName"); var testSuiteDataFilePath = DataDriver.GetTestCaseDataValueByName("TestSuiteDataFile"); //Load test suite data file var tests = ExcelFileServer2010.ReadExcelFileWithHeaders(testSuiteDataFilePath, "TestCases"); var numberOfTests = tests.ContainsKey("Name") ? tests["Name"].Count : 0; //Execute all tests for (int testRow = 0; testRow < numberOfTests; ++testRow) { var testName = tests["Name"][testRow]; var homePageURL = tests["HomePageURL"][testRow]; var testDataFilePath = tests["Path"][testRow]; GlobalReporter.StartTestCase(testSuiteName + " - " + testName); //Navigate to home page TestDriver.Actions_NavigateToURL(homePageURL); //Load current test data file var testData = ExcelFileServer2010.LoadExcelWorkbookFromExternalFileByFilePath(testDataFilePath); //Exeute functions from each section var numberOfSheets = testData.NumberOfSheets; for (int sheetIndex = 0; sheetIndex < numberOfSheets; ++sheetIndex) { var sheetReference = testData.GetSheetAt(sheetIndex); var sectionName = sheetReference.SheetName; //Skip utility sections if (sectionName.Equals("Elements") || sectionName.Equals("Actions")) { continue; } var sectionData = ExcelFileServer2010.ParseWorkbookSheet(sheetReference, 0); GlobalReporter.ReportInfo("Executing steps for: " + testName + ", function: " + sectionName); FunctionRunner.ExecuteFunctionSteps(sectionData); GlobalReporter.ReportInfo("Completed steps for: " + testName + ", function: " + sectionName); } GlobalReporter.TakeScreenShot("Final screen"); GlobalReporter.CloseTestCase(); } }
public override bool ModLoad() { DataDriver = MyBase.DataDriver; //Load the DB into memory try { if (DataDriver.DBExists("floodserv.db")) { FloodDB = DataDriver.LoadDB("floodserv.db"); if (FloodDB == null) { throw (new Exception("NickServ: Unknown DB Load Error")); // return false; } } else { MakeDB(); } BlackLight.Services.Timers.Timer FSSaveTimer; FSSaveTimer = new BlackLight.Services.Timers.Timer(new TimeSpan(0), new TimeSpan(0, 5, 0), - 1, new Timers.TimedCallBack(TimerSaveDB)); MyBase.timerController.addTimer(FSSaveTimer); MyBase.Core.events.OnFinishedNetBurst += new BlackLight.Services.Core.ServicesCore.ServicesEvents.OnFinishedNetBurstEventHandler(this.OnConnect); } catch (Exception ex) { MyBase.Core.SendLogMessage("FloodServ", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "Exception", "", ex.Message, ex.StackTrace); //show("FloodServ Error " + ex.Message + " " + ex.StackTrace); return false; } mFloodServ = new LocalClient("FloodServ",new MessageCallBack(FloodServCallBack) ,MyBase.Core); ModuleList tModules = new ModuleList(); tModules.Add(MyBase.ModuleManage.Modules["Help"]); MyService = new FloodServService(mFloodServ, MyBase.Core, FloodDB, tModules); mFloodServ.host = "services.com"; mFloodServ.modes = "S"; mFloodServ.realname = "FloodServ"; mFloodServ.time = BlackLight.Services.Converters.Time.GetTS(DateTime.Now); mFloodServ.username = "******"; MyBase.Core.events.onClientConnect += new BlackLight.Services.Core.ServicesCore.ServicesEvents.onClientConnectEventHandler(MyService.OnClientConnect); mFloodServ.Cmds.Add("HELP", new BlackLight.Services.Nodes.CommandCallBack( MyService.FSHelp)); mFloodServ.Cmds.Add("NPWATCH", new BlackLight.Services.Nodes.CommandCallBack( MyService.FSNPWatch)); mFloodServ.Cmds.Add("NSWATCH", new BlackLight.Services.Nodes.CommandCallBack( MyService.FSNSWatch)); mFloodServ.Cmds.Add("REGWATCH", new BlackLight.Services.Nodes.CommandCallBack( MyService.FSRegWatch)); mFloodServ.Cmds.Add("NPSCAN", new BlackLight.Services.Nodes.CommandCallBack( MyService.FSNPScan)); mFloodServ.Cmds.Add("NSSCAN", new BlackLight.Services.Nodes.CommandCallBack( MyService.FSNSScan)); mFloodServ.Cmds.Add("REGSCAN", new BlackLight.Services.Nodes.CommandCallBack( MyService.FSRegScan)); MyBase.Core.LocalClients.AddClient(mFloodServ); return true; }
public static void RegenerateApiExpectedData(string actualResult) { if (!DataDriver.GetSystemPropertyString("REGENERATEDATA").Contains("YES")) { return; } ExternalFileServer.SaveStringAsTextFile(actualResult, GenerateExpectedFilePath()); }
public static string GetBaseUrl() { var testEnvironment = DataDriver.GetTestEnvironment(); var iterationEnvironment = DataDriver.GetTestCaseDataValueByName(TestDataParameters.Environment.ToString()); if (!testEnvironment.ToUpper().Equals(iterationEnvironment.ToUpper())) { GlobalReporter.ReportInfo($"Current iteration target environment {iterationEnvironment} does not equal to current actual environment {testEnvironment}. Skiping iteration."); return("SKIP"); } var baseURL = DataDriver.GetTestCaseDataValueByName(TestDataParameters.BaseUrl.ToString()); return(baseURL); }
protected override void ExecuteTest() { //Pdf document tester //PDFFileTestEngine.VerifyTextExistsInPdfFile(@"C:\TestAutomationResults\Notice+of+Decision+-+256.pdf", "Abella END-TO-END-17"); GlobalReporter.ReportInfo(TestContext.TestName); var testDataFilePath = DataDriver.GetConfigurationValueInSectionByName("GlobalSettings", "TestCaseFilePath"); var testDataFileName = TestContext.TestName + ".xlsx"; string testDataFileFullPath = testDataFilePath + testDataFileName; var testName = TestContext.TestName; //Navigate to home page string homePageUrl = DataDriver.GetConfigurationValueInSectionByName("GlobalSettings", "HomePageURL"); TestDriver.Actions_NavigateToURL(homePageUrl); //Load current test data file var testData = ExcelFileServer2010.LoadExcelWorkbookFromExternalFileByFilePath(testDataFileFullPath); //Exeute functions from each section var numberOfSheets = testData.NumberOfSheets; for (int sheetIndex = 0; sheetIndex < numberOfSheets; ++sheetIndex) { var sheetReference = testData.GetSheetAt(sheetIndex); var sectionName = sheetReference.SheetName; //Skip utility sections if (sectionName.Equals("Elements") || sectionName.Equals("Actions")) { continue; } var sectionData = ExcelFileServer2010.ParseWorkbookSheet(sheetReference, 0); GlobalReporter.ReportInfo("Executing steps for: " + testName + ", function: " + sectionName); FunctionRunner.ExecuteFunctionSteps(sectionData); GlobalReporter.ReportInfo("Completed steps for: " + testName + ", function: " + sectionName); GlobalReporter.TakeScreenShot("Final screen - " + sectionName); } }
protected override void ExecuteTest() { //DataDriver.OverrideEnvironmentValueForKey("REGENERATEDATA", "YES"); //Get API test data var baseUrl = SharedSteps.GetBaseUrl(); var uri = DataDriver.GetTestCaseDataValueByName(TestDataParameters.URI.ToString()); ServiceDriver.InitializeRestClient(baseUrl + uri, HttpVerb.GET); var actualResult = ServiceDriver.ExecuteRequestAndReadIntoString(); SharedSteps.RegenerateApiExpectedData(actualResult); var expectedResults = ExternalFileServer.ReadFileAsString(SharedSteps.GenerateExpectedFilePath()); //ServiceDriver.Assertions_CompareStringMessages(expectedResults, actualResult); ServiceDriver.Assertions_CompareJsonMessages(expectedResults, actualResult); }
public static string generateDate(int age, string value) { int year = Utilities.Utility_GetCurrentDate().AddYears(age).Year; var newValue = ""; if (DataDriver.IsRuntimeDataValuePresent(value)) { newValue = DataDriver.GetRuntimeDataValueByName(value); value = newValue; } else { var _month = Utilities.Utility_GenerateRandomNumberInRange(1, 12); var _date = Utilities.Utility_GenerateRandomNumberInRange(1, 28); var _year = Utilities.Utility_GenerateRandomNumberInRange(year, year); newValue = string.Format("{0}/{1}/{2}", _date, _month, _year); DataDriver.AddRuntimeDataValueByName(value, newValue); value = newValue; } return(value); }
public override bool ModLoad() { DataDriver = MyBase.DataDriver; //Load the DB into memory try { if (DataDriver.DBExists("nickserv.db")) { NickDB = DataDriver.LoadDB("nickserv.db"); if (NickDB == null) { throw (new Exception("NickServ: Unknown DB Load Error")); // return false; } } else { MakeDB(); } BlackLight.Services.Timers.Timer NSSaveTimer; NSSaveTimer = new BlackLight.Services.Timers.Timer(new TimeSpan(0), new TimeSpan(0, 5, 0), - 1, new Timers.TimedCallBack( TimerSaveDB)); MyBase.timerController.addTimer(NSSaveTimer); MyBase.Core.events.OnFinishedNetBurst += new BlackLight.Services.Core.ServicesCore.ServicesEvents.OnFinishedNetBurstEventHandler(this.OnConnect); } catch (Exception ex) { MyBase.Core.SendLogMessage("Nick", "ModLoad", BlackLight.Services.Error.Errors.ERROR, "Exception", "", ex.Message, ex.StackTrace); //show("NickServ Error " + ex.Message + " " + ex.StackTrace); return false; } mNickServ = new LocalClient("NickServ", new MessageCallBack(NickServCallBack), MyBase.Core); ModuleList tModules = new ModuleList(); tModules.Add(MyBase.ModuleManage.Modules["Help"]); MyService = new NickServService(mNickServ, MyBase.Core, NickDB, tModules); mNickServ.host = "services.com"; mNickServ.modes = "S"; mNickServ.realname = "NickyServ"; mNickServ.time = BlackLight.Services.Converters.Time.GetTS(DateTime.Now); mNickServ.username = "******"; // Client mNickServ.Cmds.Add("REGISTER", new BlackLight.Services.Nodes.CommandCallBack( MyService.NSRegister)); // Client mNickServ.Cmds.Add("IDENTIFY", new BlackLight.Services.Nodes.CommandCallBack( MyService.NSIdentify)); // Client mNickServ.Cmds.Add("GROUP", new BlackLight.Services.Nodes.CommandCallBack( MyService.NSGroup)); // Client mNickServ.Cmds.Add("GLIST", new BlackLight.Services.Nodes.CommandCallBack( MyService.NSGList)); // Client/Oper mNickServ.Cmds.Add("DROP", new BlackLight.Services.Nodes.CommandCallBack( MyService.NSDrop)); // Client mNickServ.Cmds.Add("GHOST", new BlackLight.Services.Nodes.CommandCallBack( MyService.NSGhost)); mNickServ.Cmds.Add("HELP", new BlackLight.Services.Nodes.CommandCallBack( MyService.NSHelp)); // Client/Open - (oper gets more) // bNickServ.Cmds.Add("INFO", AddressOf MyService.NullFunction) // Client // bNickServ.Cmds.Add("LOGOUT", AddressOf MyService.NullFunction) // Client // bNickServ.Cmds.Add("RECOVER", AddressOf MyService.NullFunction) // Client // bNickServ.Cmds.Add("RELEASE", AddressOf MyService.NullFunction) // Client // bNickServ.Cmds.Add("AJOIN", AddressOf MyService.NullFunction) // Client / Oper // bNickServ.Cmds.Add("ACCESS", AddressOf MyService.NullFunction) // Client / Oper // bNickServ.Cmds.Add("ALIST", AddressOf MyService.NullFunction) // Client // bNickServ.Cmds.Add("STATUS", AddressOf MyService.NullFunction) // Client/Oper // bNickServ.Cmds.Add("SET", AddressOf MyService.NullFunction) // Oper // bNickServ.Cmds.Add("FIND", AddressOf MyService.NullFunction) // Oper // bNickServ.Cmds.Add("FORBID", AddressOf MyService.NullFunction) // Oper // bNickServ.Cmds.Add("UNFORBID", AddressOf MyService.NullFunction) // Oper // bNickServ.Cmds.Add("SUSPEND", AddressOf MyService.NullFunction) // Oper // bNickServ.Cmds.Add("UNSUSPEND", AddressOf MyService.NullFunction) // Oper - de oper/dc // bNickServ.Cmds.Add("NOOP", AddressOf MyService.NullFunction) // Oper //bNickServ.Cmds.Add("UNIDENTIFY", AddressOf MyService.NullFunction) MyBase.Core.LocalClients.AddClient(mNickServ); return true; }
public UserDao(DataDriver dataDriver) { m_DataDriver = dataDriver; m_Data = m_DataDriver.FetchData("User") as Dictionary <string, object>; }
/// <summary> /// Generates a Query object that can be executed to return only the GlobalRecordId values matching the filter conditions. This method can only be used for Epi Info 7 forms. /// </summary> /// <param name="form">The form to process</param> /// <returns>Query</returns> public virtual Query GetGuidSelectQuery(View form) { // pre Contract.Requires(form != null); // post Contract.Ensures(Contract.Result <Query>() != null); Contract.Ensures(!String.IsNullOrEmpty(Contract.Result <Query>().SqlStatement)); // assumes Contract.Assume(DataDriver != null); if (DataDriver == null) { throw new InvalidOperationException(); } if (form == null) { throw new ArgumentNullException("form"); } string baseTableName = "t"; string fromClause = form.FromViewSQL; Contract.Assert(!String.IsNullOrEmpty(fromClause)); WordBuilder columns = new WordBuilder(", "); columns.Append("[" + baseTableName + "].[GlobalRecordId]"); columns.Append("[" + baseTableName + "].[FKEY]"); columns.Append("[" + baseTableName + "].[RECSTATUS]"); if (DataDriver.ColumnExists(baseTableName, "FirstSaveLogonName")) { columns.Append("[" + baseTableName + "].[FirstSaveLogonName]"); columns.Append("[" + baseTableName + "].[FirstSaveTime]"); columns.Append("[" + baseTableName + "].[LastSaveLogonName]"); columns.Append("[" + baseTableName + "].[LastSaveTime]"); } string recStatusComparison = "[" + baseTableName + "].[RECSTATUS] = 1"; if (RecordProcessingScope == Epi.RecordProcessingScope.Both) { recStatusComparison = "[" + baseTableName + "].[RECSTATUS] >= 0"; } else if (RecordProcessingScope == Epi.RecordProcessingScope.Deleted) { recStatusComparison = "[" + baseTableName + "].[RECSTATUS] = 0"; } string fullSql = "SELECT " + columns.ToString() + " " + fromClause + " WHERE " + recStatusComparison + " AND ("; //filterSql.Append(fullSql); string logicalOperatorString = " AND "; if (_conditionJoinType == ConditionJoinTypes.Or) { logicalOperatorString = " OR "; } WordBuilder filterSql = new WordBuilder(logicalOperatorString); foreach (IRowFilterCondition rowFc in _rowFilterConditions) { filterSql.Append(rowFc.Sql); } string fSql = fullSql + " " + filterSql.ToString() + ")"; Query selectQuery = DataDriver.CreateQuery(fSql); Contract.Assert(selectQuery != null); Contract.Assert(!String.IsNullOrEmpty(selectQuery.SqlStatement)); foreach (IRowFilterCondition rowFc in _rowFilterConditions) { selectQuery.Parameters.Add(rowFc.Parameter); } return(selectQuery); }
public static void ExecuteFunctionSteps(Dictionary <string, List <string> > testData) { //Acquire number of test data rows to process var numberOfRows = testData.ContainsKey(testFileDataTabs.Action.ToString()) ? testData[testFileDataTabs.Action.ToString()].Count : 0; //Loop through all data rows for (var row = 0; row < numberOfRows; ++row) { //Get necessary object attributes and test data from current row var action = testData[testFileDataTabs.Action.ToString()][row]; var elementName = testData[testFileDataTabs.Element.ToString()][row]; var variableName = testData[testFileDataTabs.VariableName.ToString()][row] != null ? testData[testFileDataTabs.VariableName.ToString()][row] : ""; var variableValue = testData[testFileDataTabs.VariableValue.ToString()][row]; var modifier = testData[testFileDataTabs.Modifier.ToString()][row]; var optional = false; if (testData[testFileDataTabs.Optional.ToString()][row].Length > 0) { optional = bool.Parse(testData[testFileDataTabs.Optional.ToString()][row]); } var stepDescription = action + ": " + elementName + (variableValue.Length > 0 ? ", with data: " + variableValue : "."); //Get variable value by name if exists if (DataDriver.IsRuntimeDataValuePresent(variableName)) { GlobalReporter.ReportSuccess("Retreiving variable with name: " + variableName + ", and value: " + variableValue); variableValue = DataDriver.GetRuntimeDataValueByName(variableName); } //Execute action based on incoming data: Actionable steps switch (action) { case "Navigate To": { TestDriver.Actions_NavigateToURL(variableValue); break; } case "Click": { var ids = ObjectRepositoryManager.CombineElementIdentifiers(elementName); //TestDriver.Utilities_WaitForObjectToBecomeClickable(ids, 5); TestDriver.Actions_ClickOnObject(ids, "Click on: " + elementName, optional); break; } case "Click with Javascript": { var ids = ObjectRepositoryManager.CombineElementIdentifiers(elementName); TestDriver.Actions_ClickWithJavaScriptExecutor(ids, "Click on: " + elementName, optional); break; } case "Right Click": { var ids = ObjectRepositoryManager.CombineElementIdentifiers(elementName); TestDriver.Actions_RightClickOnObject(ids, "Right Click on: " + elementName, optional); break; } case "Enter Text": { var ids = ObjectRepositoryManager.CombineElementIdentifiers(elementName); TestDriver.Actions_EnterText(ids, variableValue, "Enter text: " + variableValue + ", into: " + elementName, optional); break; } case "Enter Text In Window And Press Enter": { TestDriver.Actions_EnterTextInActiveWindowAndPressEnter(variableValue); break; } case "Enter Text In Window And Press Tab": { TestDriver.Actions_EnterTextInActiveWindowAndPressTab(variableValue); break; } case "Press Tab": { TestDriver.Actions_PressTab(); break; } case "Select Drop Down Option": { var ids = ObjectRepositoryManager.CombineElementIdentifiers(elementName); if (TryAction(() => { TestDriver.Actions_SelectOptionFromDropDownByText(ids, variableValue, stepDescription, optional); }) == false) { TestDriver.Actions_SelectOptionFromDropDownByValue(ids, variableValue, stepDescription, optional); break; } break; } case "Select Drop Down Option By Index": { var ids = ObjectRepositoryManager.CombineElementIdentifiers(elementName); TestDriver.Actions_SelectOptionFromDropDownByIndex(ids, int.Parse(variableValue), stepDescription, optional); break; } case "Delay Test Execution": { TestDriver.Utilities_DelayTestExecution(int.Parse(variableValue)); break; } case "Execute Shared Function": { //Load shared functions file var sharedFunctionsFilePath = DataDriver.GetConfigurationValueInSectionByName("GlobalSettings", "SharedFunctionsFilePath") + "FunctionLibrary.xlsx"; var sharedFunctionData = ExcelFileServer2010.ReadExcelFileWithHeaders(sharedFunctionsFilePath, variableValue); if (sharedFunctionData.Count != 0) { ExecuteFunctionSteps(sharedFunctionData); } break; } case "Create Random Text Value": { var newRandomString = Utilities.Utility_GenerateRandomStringWithLengthInRange(4, 8); DataDriver.AddRuntimeDataValueByName(variableName, newRandomString); stepDescription = "Generated random value: " + newRandomString + ", with variable name: " + variableName; GlobalReporter.ReportSuccess(stepDescription); TestDriver.Utilities_DelayTestExecution(2); break; } case "Create Date Value": { var newDateString = CustomUtilities.GenerateDateBasedOnParameter(variableValue); DataDriver.AddRuntimeDataValueByName(variableName, newDateString); stepDescription = "Generated random date: " + newDateString + ", with variable name: " + variableName; GlobalReporter.ReportSuccess(stepDescription); break; } case "Create Random Date Value With Age": { try { int year = Utilities.Utility_GetCurrentDate().AddYears(int.Parse(variableValue)).Year; var month = Utilities.Utility_GenerateRandomNumberInRange(1, 12); var date = Utilities.Utility_GenerateRandomNumberInRange(1, 28); var newDate = string.Format("{0}/{1}/{2}", date, month, year); DataDriver.AddRuntimeDataValueByName(variableName, newDate); stepDescription = "Generated random date with age: " + newDate + ", variable name: " + variableName; GlobalReporter.ReportSuccess(stepDescription); } catch (Exception e) { stepDescription = "Could not generate date with age uding variable value: " + variableValue + ". Exception message: " + e; } break; } case "Set Variable Value": { DataDriver.AddRuntimeDataValueByName(variableName, variableValue); stepDescription = "Saved variable: " + variableName + ", with value: " + variableValue; GlobalReporter.ReportSuccess(stepDescription); break; } case "Set FilePath Variable Value": { variableName = "FilePath"; DataDriver.AddRuntimeDataValueByName(variableName, variableValue); stepDescription = "Saved variable: " + variableName + ", with value: " + variableValue; GlobalReporter.ReportSuccess(stepDescription); break; } case "Check Element Present": { var ids = ObjectRepositoryManager.CombineElementIdentifiers(elementName); if (TestDriver.Surveys_DoesObjectExist(ids)) { if (modifier.Equals("not")) { GlobalReporter.ReportFailure(stepDescription, !optional); } else { GlobalReporter.ReportSuccess(stepDescription); } } else { if (!modifier.Equals("not")) { GlobalReporter.ReportFailure(stepDescription, !optional); } else { GlobalReporter.ReportSuccess(stepDescription); } } break; } case "Check Element Visible": { var ids = ObjectRepositoryManager.CombineElementIdentifiers(elementName); if (TestDriver.Surveys_IsObjectVisible(ids)) { if (modifier.Equals("not")) { GlobalReporter.ReportFailure(stepDescription, !optional); } else { GlobalReporter.ReportSuccess(stepDescription); } } else { if (!modifier.Equals("not")) { GlobalReporter.ReportFailure(stepDescription, !optional); } else { GlobalReporter.ReportSuccess(stepDescription); } } break; } case "Check Element Text": { var ids = ObjectRepositoryManager.CombineElementIdentifiers(elementName); if (TestDriver.Retrievers_GetObjectText(ids).Equals(variableValue)) { if (modifier.Equals("not")) { GlobalReporter.ReportFailure(stepDescription, !optional); } else { GlobalReporter.ReportSuccess(stepDescription); } } else { if (!modifier.Equals("not")) { GlobalReporter.ReportFailure(stepDescription, !optional); } else { GlobalReporter.ReportSuccess(stepDescription); } } break; } case "Check For Text On Page": { if (TestDriver.Surveys_DoesTextExistsOnPageByFullTextValue(variableValue)) { if (modifier.Equals("not")) { GlobalReporter.ReportFailure(stepDescription, !optional); } else { GlobalReporter.ReportSuccess(stepDescription); } } else { if (!modifier.Equals("not")) { GlobalReporter.ReportFailure(stepDescription, !optional); } else { GlobalReporter.ReportSuccess(stepDescription); } } break; } case "Verify Text Present In Pdf File": { if (!DataDriver.IsRuntimeDataValuePresent("FilePath")) { GlobalReporter.ReportFailure("In oder to execute PDF file text verification function you need to first set value of special variable [FilePath].", true, false); } var filePath = DataDriver.GetRuntimeDataValueByName("FilePath"); if (modifier.Equals("not")) { PDFFileTestEngine.VerifyTextExistsInPdfFile(filePath, variableValue, false, optional); } else { PDFFileTestEngine.VerifyTextExistsInPdfFile(filePath, variableValue, true, optional); } break; } case "Capture Element Text": { var ids = ObjectRepositoryManager.CombineElementIdentifiers(elementName); var elementText = TestDriver.Retrievers_GetObjectText(ids, optional); if (elementText.Length > 0) { DataDriver.AddRuntimeDataValueByName(variableName, elementText); } else { if (optional) { GlobalReporter.ReportInfo("Text could not be caputed for element: " + elementName); } else { GlobalReporter.ReportFailure("Text could not be caputed for element: " + elementName); } } break; } case "Capture Element Attribute Value": { var ids = ObjectRepositoryManager.CombineElementIdentifiers(elementName); var attributeValue = TestDriver.Retrievers_GetObjectAttributeByName(ids, variableValue, optional); if (attributeValue.Length > 0) { DataDriver.AddRuntimeDataValueByName(variableName, attributeValue); } else { if (optional) { GlobalReporter.ReportInfo("Value of attribute: " + variableValue + ", could not be caputed for element: " + elementName); } else { GlobalReporter.ReportFailure("Value of attribute: " + variableValue + ", could not be caputed for element: " + elementName); } } break; } default: { GlobalReporter.ReportWarning("Current action: " + action + ", has not been mapped to an executable step. Please make sure you are using correct test template."); break; } } } }
private void initialize() { // 0.初始化路径 if (!Directory.Exists(Common.BrightnessFolder)) { Directory.CreateDirectory(Common.BrightnessFolder); } if (!Directory.Exists(Common.BrightnessTrainedFolder)) { Directory.CreateDirectory(Common.BrightnessTrainedFolder); } // 1.加载配置文件 Common.Config = Config.Load(Common.ConfigPath); if (Common.Config == null) { Common.Config = new Config(true); } Common.Config.UpdateTime = DateTime.Now; Common.Config.Save(); /* * 2.初始化控件 */ // 2.1 主窗体控件 this.ShowInTaskbar = false; this.notifyIcon1.Visible = true; this.btnHidden.Location = new System.Drawing.Point(0, -100); // 2.2 遮罩窗体 //this._shade.Text = this.Text; // 2.3 tabMain this.tabMain_SelectedIndexChanged(this, null); // 2.4 tabMain - 亮度调整 this.tbAlpha.Value = Common.Config.Alpha; this.lblAlphaValue.Text = Common.Config.Alpha.ToString(); this.tbSystem.Enabled = this._screenBrightness.Initiazlie(); if (this.tbSystem.Enabled) { this.tbSystem.Maximum = this._screenBrightness.Maximum; this._tbSystemToScreenBrightness = this._screenBrightness.GetBrightness(); // 读取系统亮度 this.lblSystem.Text = this.tbSystem.Value.ToString(); } // 2.5 tabMain - 多屏设置 this.listView1.Items.Clear(); var monitorCount = Math.Max(Common.Config.Monitors.Count, Screen.AllScreens.Length); // 读取配置文件和系统屏幕中屏幕数量多的,作为显示器控件数量添加到listview中 var screens = Screen.AllScreens.OrderBy(m => m.Bounds.X).ToArray(); // 按屏幕X轴位置排序 for (int i = 0; i < monitorCount; i++) { // 2.5.1 添加控件 this.listView1.Items.Add(new ListViewItem() { ImageIndex = (i < Common.Config.Monitors.Count && Common.Config.Monitors[i].Enabled) || Common.Config.IsFirtConfig ? 0 : 1 }); // 2.5.2 添加屏幕配置 if (monitorCount > Common.Config.Monitors.Count) { Common.Config.Monitors.Add(new Monitor()); // 将缺少的屏幕添加到配置文件 } // 2.5.3 读取屏幕配置 var m = Common.Config.Monitors[i]; if (i < screens.Length) { m.Primary = screens[i].Primary; // 设置主显 m.Width = screens[i].Bounds.Width; m.Height = screens[i].Bounds.Height; m.X = screens[i].Bounds.X; m.Y = screens[i].Bounds.Y; } else { if (m.Width == 0) { m.Width = Screen.PrimaryScreen.Bounds.Width; m.Height = Screen.PrimaryScreen.Bounds.Height; } } if (Common.Config.IsFirtConfig) { m.Enabled = true; // 第一次配置,启用所有屏幕 } // 2.5.4 添加遮罩窗体 if (i < Screen.AllScreens.Length) { this._shades.Add(new FormShade() { Text = this.Text }); } } this.listView1.Items[0].Selected = true; this.txtResolution.BorderStyle = BorderStyle.None; // 2.6 tabMain - 软件设置 this.ckxAutoHidden.Checked = Common.Config.AutoHidden; this.ckxAutoShowShade.Checked = Common.Config.AutoShowShade; this.ckxAutoAdjust.Checked = Common.Config.AutoAdjust; // 3.托盘菜单 this.menuItemHidden.Text = "显示(&D)"; // 4.调整亮度 this.setBrightness(); // 调整遮罩亮度 this._shades.ForEach(m => m.AdjustShade(Common.Config.Monitors[this._shades.IndexOf(m)])); this.ckxAlpha.Checked = Common.Config.AutoShowShade; // 显示遮罩 // 5.主窗体显示控制 if (Common.Config.AutoHidden) // 隐藏主窗体 { this.Visible = false; } else // 不自动隐藏主窗体时,激活主窗体 { this.Activate(); } // 6.启动数据驱动 if (this._dataDriver == null) { if (Common.Config.AutoAdjust && File.Exists(Common.Config.BrightnessDataPath)) { // 加载亮度数据 try { Common.BrightnessDatas = new SharpSerializer().Deserialize(Common.Config.BrightnessDataPath) as List <BrightnessData>; } catch { } } this._dataDriver = new DataDriver(); this._dataDriver.AdjustBrightness += _dataDriver_AdjustBrightness; this._dataDriver.BrightnessGenerated += _dataDriver_BrightnessGenerated; this._dataDriver.Start(); } }