/// <summary> /// Инициалиация контролов формы, которые будем тестировать. /// </summary> private void InitUiControls() { riskSetupControl = window.Items.FirstOrDefault(x => x.Id == "riskSetupControl") as Panel; Assert.NotNull(riskSetupControl, string.Format("Ссылка на элемент {0} равна null.", riskSetupControl)); tbTickerCount = riskSetupControl.Items.FirstOrDefault(x => x.Id == "tbTickerCount") as WinFormTextBox; Assert.NotNull(tbTickerCount, string.Format("Ссылка на элемент {0} равна null.", tbTickerCount)); tbDealByTickerCount = riskSetupControl.Items.FirstOrDefault(x => x.Id == "tbDealByTickerCount") as WinFormTextBox; Assert.NotNull(tbDealByTickerCount, string.Format("Ссылка на элемент {0} равна null.", tbDealByTickerCount)); tbLeverage = riskSetupControl.Items.FirstOrDefault(x => x.Id == "tbLeverage") as WinFormTextBox; Assert.NotNull(tbLeverage, string.Format("Ссылка на элемент {0} равна null.", tbLeverage)); tbBalance = riskSetupControl.Items.FirstOrDefault(x => x.Id == "tbBalance") as WinFormTextBox; Assert.NotNull(tbBalance, string.Format("Ссылка на элемент {0} равна null.", tbBalance)); tbOrderLeverage = riskSetupControl.Items.FirstOrDefault(x => x.Id == "tbOrderLeverage") as WinFormTextBox; Assert.NotNull(tbOrderLeverage, string.Format("Ссылка на элемент {0} равна null.", tbOrderLeverage)); tbResultedVolume = riskSetupControl.Items.FirstOrDefault(x => x.Id == "tbResultedVolume") as WinFormTextBox; Assert.NotNull(tbResultedVolume, string.Format("Ссылка на элемент {0} равна null.", tbResultedVolume)); tbResultRounded = riskSetupControl.Items.FirstOrDefault(x => x.Id == "tbResultRounded") as WinFormTextBox; Assert.NotNull(tbResultRounded, string.Format("Ссылка на элемент {0} равна null.", tbResultRounded)); cbTicker = riskSetupControl.Items.First(x => x.Id == "cbTicker") as TestStack.White.UIItems.ListBoxItems.ComboBox; Assert.NotNull(tbResultRounded, string.Format("Ссылка на элемент {0} равна null.", cbTicker)); }
public void TestRunFileConfiguration() { ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); configFile.Children.Add(setupConfiguration); string configFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); Console.WriteLine("Writing '{0}'", configFileName); configFile.SaveAs(configFileName); try { ProcessStartInfo pi = new ProcessStartInfo(InstallerEditorExeUtils.Executable, "\"" + configFileName + "\""); using (Application installerEditor = Application.Launch(pi)) { string title = string.Format("Installer Editor - {0}", configFileName); Window mainWindow = installerEditor.GetWindow(title, InitializeOption.NoCache); Tree configurationTree = UIAutomation.Find <Tree>(mainWindow, "configurationTree"); Assert.AreEqual("Config File", configurationTree.SelectedNode.Name); StatusStrip statusStrip = UIAutomation.Find <StatusStrip>(mainWindow, "statusStrip"); WinFormTextBox statusLabel = (WinFormTextBox)statusStrip.Items[0]; Assert.AreEqual(string.Format("Loaded {0}", configFileName), statusLabel.Text); } } finally { File.Delete(configFileName); } }
public void TestSaveConfiguration() { ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); configFile.Children.Add(setupConfiguration); string configFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); Console.WriteLine("Writing '{0}'", configFileName); configFile.SaveAs(configFileName); try { ProcessStartInfo pi = new ProcessStartInfo(InstallerEditorExeUtils.Executable, "\"" + configFileName + "\""); using (Application installerEditor = Application.Launch(pi)) { Window mainWindow = installerEditor.GetWindow( string.Format("Installer Editor - {0}", configFileName), InitializeOption.NoCache); StatusStrip statusStrip = UIAutomation.Find <StatusStrip>(mainWindow, "statusStrip"); WinFormTextBox statusLabel = (WinFormTextBox)statusStrip.Items[0]; Assert.AreEqual(string.Format("Loaded {0}", configFileName), statusLabel.Text); UIAutomation.Find <MenuBar>(mainWindow, "Application").MenuItem("Edit", "Add", "Configurations", "Setup Configuration").Click(); UIAutomation.Find <MenuBar>(mainWindow, "Application").MenuItem("File", "Save").Click(); Assert.AreEqual(string.Format("Written {0}", configFileName), statusLabel.Text); ConfigFile savedConfigFile = new ConfigFile(); savedConfigFile.Load(configFileName); Assert.AreEqual(2, savedConfigFile.Children.Count); } } finally { File.Delete(configFileName); } }
public Window Load_LoginForm_Submit_ValidSignIn_Load_SelectFacility(Window window) { window = application.GetWindow("Login", InitializeOption.NoCache); WinFormTextBox login = window.Get <WinFormTextBox>(SearchCriteria.ByAutomationId("username")); WinFormTextBox password = window.Get <WinFormTextBox>(SearchCriteria.ByAutomationId("password")); Button okButton = window.Get <Button>(SearchCriteria.ByAutomationId("okButton")); login.Click(); login.BulkText = "jorussell"; password.Click(); password.BulkText = "KillingMeSoftly25"; okButton.DoubleClick(); List <Window> newWindows = application.GetWindows(); Assert.IsTrue(newWindows.Count == 1); Assert.IsTrue(newWindows[0].Name == "Select Facility"); Assert.IsTrue(newWindows[0].Title == "Select Facility"); window.Close(); return(newWindows[0]); }
public void TestStatusReady() { using (Application installerEditor = Application.Launch(InstallerEditorExeUtils.Executable)) { Window mainWindow = installerEditor.GetWindow("Installer Editor", InitializeOption.NoCache); StatusStrip statusStrip = UIAutomation.Find <StatusStrip>(mainWindow, "statusStrip"); WinFormTextBox statusLabel = (WinFormTextBox)statusStrip.Items[0]; Assert.AreEqual("Ready", statusLabel.Text); } }
public Login(Application application) { WindowTools windowTools = new WindowTools(); Window window = windowTools.GetWindow(application, "Login"); WinFormTextBox usernameTextBox = windowTools.GetIUIItem <WinFormTextBox>(window, SearchCriteria.ByAutomationId("username")); WinFormTextBox passwordTextBox = windowTools.GetIUIItem <WinFormTextBox>(window, SearchCriteria.ByAutomationId("password")); Button okButton = windowTools.GetButton(window, SearchCriteria.ByAutomationId("okButton")); windowTools.ClickIUIItem(usernameTextBox); windowTools.PostText(usernameTextBox, username); windowTools.ClickIUIItem(passwordTextBox); windowTools.PostText(passwordTextBox, password); windowTools.DoubleClickIUItem(okButton); }
public void TestNewConfiguration() { using (Application installerEditor = Application.Launch(InstallerEditorExeUtils.Executable)) { Window mainWindow = installerEditor.GetWindow("Installer Editor", InitializeOption.NoCache); UIAutomation.Find <MenuBar>(mainWindow, "Application").TopLevelMenu.Find("File").Click(); UIAutomation.Find <MenuBar>(mainWindow, "Application").TopLevelMenu.Find("File").ChildMenus.Find("New").Click(); // status says "Ready" StatusStrip statusStrip = UIAutomation.Find <StatusStrip>(mainWindow, "statusStrip"); WinFormTextBox statusLabel = (WinFormTextBox)statusStrip.Items[0]; Assert.AreEqual("Ready", statusLabel.Text); // configuration tree has one node Tree configurationTree = UIAutomation.Find <Tree>(mainWindow, "configurationTree"); Assert.AreEqual(1, configurationTree.Nodes.Count); Assert.AreEqual(0, configurationTree.SelectedNode.Nodes.Count); Assert.AreEqual("Config File", configurationTree.SelectedNode.Text); } }
public Search_ClientCaseSearch(Application application, string searchText) { WindowTools windowTools = new WindowTools(); List <Window> windows = windowTools.GetWindows(application); Window window = windowTools.GetWindow(windows, "ClientCaseSearch"); WinFormTextBox textBox = windowTools.GetIUIItem <WinFormTextBox>(window, SearchCriteria.ByAutomationId("criteria")); windowTools.PostText(textBox, searchText); Button lastNameButton = windowTools.GetButton(window, SearchCriteria.ByAutomationId("lastNameButton")); windowTools.DoubleClickIUItem(lastNameButton); windows = windowTools.GetWindows(application); if (windows.Count > 2) { windows[2].Items[0].DoubleClick(); Button newClientButton = windowTools.GetButton(window, SearchCriteria.ByAutomationId("newClientButton")); windowTools.DoubleClickIUItem(newClientButton); } }
public void TestSaveAsConfiguration() { string configFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); try { using (Application installerEditor = Application.Launch(InstallerEditorExeUtils.Executable)) { Window mainWindow = installerEditor.GetWindow("Installer Editor", InitializeOption.NoCache); UIAutomation.Find <MenuBar>(mainWindow, "Application").MenuItem("File", "New").Click(); UIAutomation.Find <MenuBar>(mainWindow, "Application").MenuItem("Edit", "Add", "Configurations", "Setup Configuration").Click(); Menu mainMenuFile = UIAutomation.Find <MenuBar>(mainWindow, "Application").MenuItem("File"); mainMenuFile.Click(); Assert.IsFalse(mainMenuFile.ChildMenus.Find("Save").Enabled); mainMenuFile.ChildMenus.Find("Save As...").Click(); Window openWindow = mainWindow.ModalWindow("Save As"); TextBox filenameTextBox = openWindow.Get <TextBox>("File name:"); filenameTextBox.Text = configFileName; openWindow.KeyIn(KeyboardInput.SpecialKeys.RETURN); openWindow.WaitWhileBusy(); mainWindow.WaitWhileBusy(); Assert.IsTrue(File.Exists(configFileName)); Assert.IsTrue(UIAutomation.Find <MenuBar>(mainWindow, "Application").MenuItem("File", "Save").Enabled); StatusStrip statusStrip = UIAutomation.Find <StatusStrip>(mainWindow, "statusStrip"); WinFormTextBox statusLabel = (WinFormTextBox)statusStrip.Items[0]; Assert.AreEqual(string.Format("Written {0}", configFileName), statusLabel.Text); ConfigFile savedConfigFile = new ConfigFile(); savedConfigFile.Load(configFileName); Assert.AreEqual(1, savedConfigFile.Children.Count); } } finally { if (File.Exists(configFileName)) { File.Delete(configFileName); } } }
public Window In_ClientCaseSearch_Enable_NewClientButton_Load_AddClientCase(Window window) { WinFormTextBox criteria = window.Get <WinFormTextBox>(SearchCriteria.ByAutomationId("criteria")); criteria.Text = "ZZZZZZZZZZZZZZZZZZZZ"; //unlikely to be a last name Button search = window.Get <Button>(SearchCriteria.ByAutomationId("lastNameButton")); search.DoubleClick(); List <Window> newWindows = application.GetWindows(); //If Client Name not found close "Client not found window" if (newWindows.Count == 3) { newWindows[2].Items[0].DoubleClick(); } window.Items[4].DoubleClick(); newWindows = application.GetWindows(); return(newWindows[2]); }
public void TestOpenCloseConfiguration() { ConfigFile configFile = new ConfigFile(); SetupConfiguration setupConfiguration = new SetupConfiguration(); configFile.Children.Add(setupConfiguration); string configFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml"); Console.WriteLine("Writing '{0}'", configFileName); configFile.SaveAs(configFileName); try { using (Application installerEditor = Application.Launch(InstallerEditorExeUtils.Executable)) { Window mainWindow = installerEditor.GetWindow("Installer Editor", InitializeOption.NoCache); UIAutomation.Find <MenuBar>(mainWindow, "Application").MenuItem("File", "Open...").Click(); Window openWindow = mainWindow.ModalWindow("Open"); TextBox filenameTextBox = openWindow.Get <TextBox>("File name:"); filenameTextBox.Text = configFileName; openWindow.KeyIn(KeyboardInput.SpecialKeys.RETURN); mainWindow.WaitWhileBusy(); Tree configurationTree = UIAutomation.Find <Tree>(mainWindow, "configurationTree"); Assert.AreEqual("Config File", configurationTree.SelectedNode.Name); StatusStrip statusStrip = UIAutomation.Find <StatusStrip>(mainWindow, "statusStrip"); WinFormTextBox statusLabel = (WinFormTextBox)statusStrip.Items[0]; Assert.AreEqual(string.Format("Loaded {0}", configFileName), statusLabel.Text); UIAutomation.Find <MenuBar>(mainWindow, "Application").MenuItem("File", "Close").Click(); Assert.AreEqual(0, configurationTree.Nodes.Count); Assert.AreEqual("Ready", statusLabel.Text); } } finally { File.Delete(configFileName); } }
protected override void TestFixtureSetUp() { textBox = (WinFormTextBox)Window.Get <TextBox>("textBox"); }