/// <summary> /// Import Wrong Format XML file /// </summary> public static void ImportWrongFormat(MainWindow mainWindow, string windowTitle) { mainWindow.Ribbon.ImportButton.Click(); ImportKeyWizard importWindow = new ImportKeyWizard(mainWindow.MainElement, windowTitle); Thread.Sleep(1000); TextLog.LogMessage("Launch Import Window " + mainWindow.Title); importWindow.ImportKeysCBR.Click(); Thread.Sleep(1000); importWindow.MainElement.SetFocus(); TextLog.LogMessage("Choose Import Keys/CBR."); importWindow.NextButton.Click(); importWindow.PathTextbox.SetValue(@"C:\Program Files (x86)\DIS Solution\OEM\Key Management Tool\ExportKey Files\Keys_2011_11_07_05_13_42.xml"); TextLog.LogMessage("Set value to Path textBox."); importWindow.MainElement.SetFocus(); Thread.Sleep(1000); importWindow.OKButton.Click(); ProgressBarisFinish(importWindow.ProgressBar, 3); string ExpectErrorStr = ""; Thread.Sleep(1000); string ActualErrorStr = importWindow.MessageBoxError.Text; TextLog.LogMessage("Compare two string : Expect string [" + ExpectErrorStr + "], Actual string [" + ActualErrorStr + "]"); bool Result = Helper.CompareTwoStr(ExpectErrorStr, ActualErrorStr) == true ? true : false; Verification.AssertKMTResponse(Result, MethodBase.GetCurrentMethod().Name + "Test case "); importWindow.CloseButton.Click(); }
/// <summary> /// Import Keys from ULS /// </summary> /// <param name="mainWindow"></param> public static void ImportKeyFromULS(MainWindow mainWindow, string windowTitle, importType type) { bool TestResult = false; mainWindow.Ribbon.ImportButton.Click(); ImportKeyWizard importWindow = new ImportKeyWizard(mainWindow.MainElement, windowTitle); Thread.Sleep(1000); TextLog.LogMessage("Launch Import Window " + mainWindow.Title); switch (type) { case importType.ImportKeyOrCBR: importWindow.ImportKeysCBR.Click(); break; case importType.ImportDupCBR: importWindow.ImportDupCBR.Click(); break; case importType.ImportOAFile: importWindow.ImportOAtool.Click(); break; default: break; } Thread.Sleep(1000); TextLog.LogMessage("Choose Import Keys/CBR."); importWindow.NextButton.Click(); if (ReaderXML.testModule.Case[ReaderXML.CurrentCase].Input["Path"].Trim() == "") { TextLog.LogMessage("There are not any Data in the Path!"); ReaderXML.testModule.Case[ReaderXML.CurrentCase].Result = TestResult == true ? TestCase.CaseResult.Pass : TestCase.CaseResult.Fail; Verification.AssertKMTResponse(TestResult, ReaderXML.CurrentCase + " Test case "); Helper.CloseApp(importWindow.MainElement); return; } importWindow.PathTextbox.SetValue(ReaderXML.testModule.Case[ReaderXML.CurrentCase].Input["Path"]); TextLog.LogMessage("Set value to Path textBox."); Thread.Sleep(1000); importWindow.MainElement.SetFocus(); if (importWindow.OKButton.isEnable == false) { int i = 0; do { Thread.Sleep(1000); i = i + 500; } while (importWindow.OKButton.isEnable == false && i < 5000); importWindow.MainElement.SetFocus(); } if (importWindow.OKButton.isEnable == false) { TextLog.LogMessage("OK button is disable!!!"); importWindow.CloseButton.Click(); Verification.AssertKMTResponse(TestResult, ReaderXML.CurrentCase + " Test case "); return; } importWindow.OKButton.Click(); TextLog.LogMessage("Import in progess...."); Thread.Sleep(1000); ProgressBarisFinish(importWindow.ProgressBar, 3); string ActualcellVaule = ""; string ExpectcellVaule = ReaderXML.testModule.Case[ReaderXML.CurrentCase].Input["Key"]; string ExpectFailReason = ""; string ActualFailReason = ""; string ActualTotal = ""; string ExpectTotal = ReaderXML.testModule.Case[ReaderXML.CurrentCase].Input["Quantity"]; bool ValueResult = false; bool TotalResult = false; TextLog.LogMessage("Get Actual Cell from DataGrid : " + ExpectcellVaule + "\n" + ExpectFailReason); if (importWindow.DataGridSummary.GridPattern.Current.RowCount > 0) { ActualcellVaule = importWindow.DataGridSummary.GetValue(0, 1); TextLog.LogMessage("Get Actual Cell from DataGrid : " + ActualcellVaule); ActualTotal = importWindow.LabelTotalKeys.text.Trim(); ExpectTotal = importWindow.DataGridSummary.GridPattern.Current.RowCount.ToString(); ActualFailReason = importWindow.DataGridSummary.GetValue(0, 3); TextLog.LogMessage("Get Total from DataGrid , \n Actual: " + ActualTotal + " \n Expect: " + ExpectTotal); TextLog.LogMessage("Get FailReason from DataGrid , \n Actual: " + ActualFailReason + " \n Expect: " + ExpectFailReason); ValueResult = Helper.CompareTwoStr(ActualcellVaule, ExpectcellVaule); TotalResult = Helper.CompareTwoStr(ActualTotal, ExpectTotal); bool ReasonReasult = Helper.CompareTwoStr(ActualFailReason, ExpectFailReason); TextLog.LogMessage("Compare Total keys and Produc key."); } else { TextLog.LogMessage("There are not key in the Summary DataGrid!"); } TestResult = ValueResult && TotalResult == true ? true : false; Verification.AssertKMTResponse(TestResult, ReaderXML.CurrentCase + " Test case "); importWindow.CloseButton.Click(); }