public void TestMalformedDocument() { CheckBoxTester control = new CheckBoxTester("control", CurrentWebForm); Browser.GetPage(BaseUrl + "MalformedTestPage.aspx"); AssertVisibility(control, true); }
public void GivenDialog_WhenSurfaceLinesSelectedAndCheckboxChecked_ThenDoForSelectedButtonEnabled(IEnumerable <Func <PipingSurfaceLineSelectionDialog, CheckBoxTester> > getCheckBoxFuncs) { // Given var surfaceLines = new[] { new PipingSurfaceLine("surface line 1"), new PipingSurfaceLine("surface line 2") }; using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, surfaceLines)) { dialog.Show(); var selectionView = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject; selectionView.Rows[0].Cells[0].Value = true; foreach (Func <PipingSurfaceLineSelectionDialog, CheckBoxTester> getCheckBoxFunc in getCheckBoxFuncs) { CheckBoxTester checkBox = getCheckBoxFunc(dialog); checkBox.Check(); } var buttonTester = new ButtonTester("DoForSelectedButton", dialog); // When var button = (Button)buttonTester.TheObject; // Then Assert.IsTrue(button.Enabled); } }
public void TestAutoPostBack() { CheckBoxTester autoPostBack = new CheckBoxTester("autoPostBack"); autoPostBack.Checked = true; Assert.IsTrue(autoPostBack.Checked, "autoPostBack should be checked"); }
public void GivenDialog_WhenSurfaceLinesSelectedAndNoCheckboxesChecked_ThenDoForSelectedButtonDisabled() { // Given var surfaceLines = new[] { new PipingSurfaceLine("surface line 1"), new PipingSurfaceLine("surface line 2") }; using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, surfaceLines)) { dialog.Show(); var selectionView = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject; selectionView.Rows[0].Cells[0].Value = true; var semiProbabilisticCheckbox = new CheckBoxTester("SemiProbabilisticCheckBox", dialog); semiProbabilisticCheckbox.UnCheck(); var buttonTester = new ButtonTester("DoForSelectedButton", dialog); // When var button = (Button)buttonTester.TheObject; // Then Assert.IsFalse(button.Enabled); } }
// public ToolStripMenuItemTester mniFile; // public System.Windows.Forms.ToolStripMenuItem mniFileSave; // public System.Windows.Forms.ToolStripSeparator mniSeparator0; // public System.Windows.Forms.ToolStripMenuItem mniFilePrint; // public System.Windows.Forms.ToolStripSeparator mniSeparator1; // public System.Windows.Forms.ToolStripMenuItem mniClose; // public System.Windows.Forms.ToolStripMenuItem mniEdit; // public System.Windows.Forms.ToolStripMenuItem mniEditUndoCurrentField; // public System.Windows.Forms.ToolStripMenuItem mniEditUndoScreen; // public System.Windows.Forms.ToolStripSeparator mniSeparator2; // public System.Windows.Forms.ToolStripMenuItem mniEditFind; // public System.Windows.Forms.ToolStripMenuItem mniAccounts; // public System.Windows.Forms.ToolStripMenuItem mniAddNewAccount; // public System.Windows.Forms.ToolStripMenuItem mniDeleteUnusedAccount; // public System.Windows.Forms.ToolStripSeparator mniSeparator3; // public System.Windows.Forms.ToolStripMenuItem mniExportHierarchy; // public System.Windows.Forms.ToolStripMenuItem mniImportHierarchy; // public System.Windows.Forms.ToolStripMenuItem mniHelp; // public System.Windows.Forms.ToolStripMenuItem mniHelpPetraHelp; // public System.Windows.Forms.ToolStripSeparator mniSeparator4; // public System.Windows.Forms.ToolStripMenuItem mniHelpBugReport; // public System.Windows.Forms.ToolStripSeparator mniSeparator5; // public System.Windows.Forms.ToolStripMenuItem mniHelpAboutPetra; // public System.Windows.Forms.ToolStripMenuItem mniHelpDevelopmentTeam; // Contructor which initializes the acces to all the controls on the // Dialog /// <summary> /// ... /// </summary> public TFrmGLAccountHierarchyTester() { mainForm = new TFrmGLAccountHierarchy(null); trvAccounts = new TTrvTreeViewTester("trvAccounts", mainForm); txtDetailAccountCode = new TextBoxTester("txtDetailAccountCode", mainForm); cmbDetailAccountType = new TCmbAutoCompleteTester("cmbDetailAccountType", mainForm); txtDetailEngAccountCodeLongDesc = new TextBoxTester("txtDetailEngAccountCodeLongDesc", mainForm); txtDetailEngAccountCodeShortDesc = new TextBoxTester("txtDetailEngAccountCodeShortDesc", mainForm); txtDetailAccountCodeLongDesc = new TextBoxTester("txtDetailAccountCodeLongDesc", mainForm); txtDetailAccountCodeShortDesc = new TextBoxTester("txtDetailAccountCodeShortDesc", mainForm); cmbDetailValidCcCombo = new TCmbAutoCompleteTester("cmbDetailValidCcCombo", mainForm); chkDetailBankAccountFlag = new CheckBoxTester("chkDetailBankAccountFlag", mainForm); chkDetailAccountActiveFlag = new CheckBoxTester("chkDetailAccountActiveFlag", mainForm); tbbSave = new ToolStripButtonTester("tbbSave", mainForm); tbbAddNewAccount = new ToolStripButtonTester("tbbAddNewAccount", mainForm); tbbDeleteUnusedAccount = new ToolStripButtonTester("tbbDeleteUnusedAccount", mainForm); tbbExportHierarchy = new ToolStripButtonTester("tbbExportHierarchy", mainForm); tbbImportHierarchy = new ToolStripButtonTester("tbbImportHierarchy", mainForm); chkDetailForeignCurrencyFlag = new CheckBoxTester("chkDetailForeignCurrencyFlag", mainForm); cmbDetailForeignCurrencyCode = new TCmbAutoPopulatedTester("cmbDetailForeignCurrencyCode", mainForm); mniClose = new ToolStripMenuItemTester("mniClose", mainForm); }
protected override void SetUp() { base.SetUp(); multiSelect = new CheckBoxTester("multi", CurrentWebForm); Browser.GetPage(BaseUrl + "/AspTester/ListBoxTestPage.aspx"); }
public void CheckUnCheck() { CheckBoxTestForm form = new CheckBoxTestForm(); form.Show(); TestWriter writer = new TestWriter(form); Assert.Equal("", writer.Test); CheckBoxTester checkBox = new CheckBoxTester("myCheckBox", form); checkBox.Click(); checkBox.Click(); Assert.Equal( @"[Fact] public void Test() { CheckBoxTester myCheckBox = new CheckBoxTester(""myCheckBox""); myCheckBox.Check(); myCheckBox.UnCheck(); }", writer.Test); }
protected override void SetUp() { base.SetUp(); CheckBox = new CheckBoxTester("checkBox", CurrentWebForm); DisabledCheckBox = new CheckBoxTester("disabled", CurrentWebForm); Submit = new LinkButtonTester("submit", CurrentWebForm); Browser.GetPage(BaseUrl + "/AspTester/CheckBoxTestPage.aspx"); }
public void OpenViewForData_SelectDifferentDefaultViewAndClickOkInOpenedDialog_ReturnTrueViewAddedToViewHostAndDefaultViewTypesUpdated() { // Setup TestView view = null; var mocks = new MockRepository(); var dialogParent = mocks.Stub <IWin32Window>(); var viewHost = mocks.StrictMock <IViewHost>(); viewHost.Stub(vh => vh.ViewClosed += null).IgnoreArguments(); viewHost.Stub(vh => vh.ViewClosed -= null).IgnoreArguments(); viewHost.Stub(vh => vh.DocumentViews).Return(new IView[0]); viewHost.Expect(vm => vm.AddDocumentView(Arg <TestView> .Is.NotNull, Arg <string> .Is.Anything, Arg <string> .Is.Null, Arg <FontFamily> .Is.Null)) .WhenCalled(invocation => { view = invocation.Arguments[0] as TestView; }); mocks.ReplayAll(); var data = new object(); var viewInfos = new ViewInfo[] { new ViewInfo <object, TestViewDerivative>(), new ViewInfo <object, TestView>() }; using (var documentViewController = new DocumentViewController(viewHost, viewInfos, dialogParent)) { documentViewController.DefaultViewTypes[typeof(object)] = typeof(TestViewDerivative); DialogBoxHandler = (name, wnd) => { var buttonOk = new ControlTester("buttonOk"); var listBox = new ListBoxTester("listBox"); var checkBox = new CheckBoxTester("checkBoxDefault"); listBox.SetSelected(0, true); checkBox.Check(); buttonOk.Click(); }; // Call bool result = documentViewController.OpenViewForData(data, true); // Assert Assert.IsTrue(result); Assert.AreEqual(data, view.Data); Assert.IsEmpty(view.Text); Assert.IsTrue(documentViewController.DefaultViewTypes.ContainsKey(typeof(object))); Assert.AreEqual(documentViewController.DefaultViewTypes[typeof(object)], typeof(TestView)); } mocks.VerifyAll(); }
public void SelectingStartupExitPageLoadsSettings() { ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm); listViewTester.Select("Startup/Exit"); CheckBoxTester checkboxTester = new CheckBoxTester("chkSaveConsOnExit", _optionsForm); Assert.That(checkboxTester.Text, Does.Match("Save connections")); }
public void SelectingTabsPanelPageLoadsSettings() { ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm); listViewTester.Select("Tabs & Panels"); CheckBoxTester checkboxTester = new CheckBoxTester("chkAlwaysShowPanelTabs", _optionsForm); Assert.That(checkboxTester.Text, Does.Match("Always show panel tabs")); }
public void SelectingUpdatesPageLoadsSettings() { ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm); listViewTester.Select("Updates"); CheckBoxTester checkboxTester = new CheckBoxTester("chkCheckForUpdatesOnStartup", _optionsForm); Assert.That(checkboxTester.Text, Does.Match("Check for updates")); }
public void SelectingConnectionsPageLoadsSettings() { ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm); listViewTester.Select("Connections"); CheckBoxTester checkboxTester = new CheckBoxTester("chkSingleClickOnConnectionOpensIt", _optionsForm); Assert.That(checkboxTester.Text, Does.Match("Single click on connection")); }
public void SelectingAppearancePageLoadsSettings() { ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm); listViewTester.Select("Appearance"); CheckBoxTester checkboxTester = new CheckBoxTester("chkShowSystemTrayIcon", _optionsForm); Assert.That(checkboxTester.Text, Does.Match("show notification area icon")); }
public void SelectingAdvancedPageLoadsSettings() { ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm); listViewTester.Select("Advanced"); CheckBoxTester checkboxTester = new CheckBoxTester("chkWriteLogFile", _optionsForm); Assert.That(checkboxTester.Text, Does.Match("Write log file")); }
public void SelectingSQLPageLoadsSettings() { ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm); listViewTester.Select("SQL Server"); CheckBoxTester checkboxTester = new CheckBoxTester("chkUseSQLServer", _optionsForm); Assert.That(checkboxTester.Text, Does.Match("Use SQL")); }
protected override void SetUp() { base.SetUp(); list = CreateListControl("list", CurrentWebForm); emptyList = CreateListControl("emptyList", CurrentWebForm); disabledList = CreateListControl("disabledList", CurrentWebForm); submit = new LinkButtonTester("submit", CurrentWebForm); clearSelection = new LinkButtonTester("clearSelection", CurrentWebForm); autoPostBack = new CheckBoxTester("auto", CurrentWebForm); indexChanged = new LabelTester("indexChanged", CurrentWebForm); }
public void TestClickingOfCheckBoxUpdatesBO() { //---------------Set up test pack------------------- _cb.Name = "TestCheckBox"; _cb.Checked = false; _sampleBusinessObject.SampleBoolean = false; _mapper.BusinessObject = _sampleBusinessObject; Form frm = AddControlToForm(_cb); //---------------Execute Test ---------------------- frm.Show(); CheckBoxTester box = new CheckBoxTester("TestCheckBox"); box.Click(); box.Check(); //---------------Test Result ----------------------- Assert.IsTrue(_cb.Checked); Assert.IsTrue(_sampleBusinessObject.SampleBoolean); //---------------Tear down ------------------------- }
public void GivenDialog_WhenChangingProbabilisticCheckBoxValue_ThenGenerateProbabilisticExpectedValue(bool checkBoxChecked) { // Given using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, Enumerable.Empty <PipingSurfaceLine>())) { dialog.Show(); // When var probabilisticCheckBox = new CheckBoxTester("ProbabilisticCheckBox", dialog); if (checkBoxChecked) { probabilisticCheckBox.Check(); } else { probabilisticCheckBox.UnCheck(); } // Then Assert.AreEqual(checkBoxChecked, dialog.GenerateProbabilistic); } }
public void Constructor_ControlsCorrectlyInitialized() { // Call using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, Enumerable.Empty <PipingSurfaceLine>())) { // Assert var selectAllButton = new ButtonTester("SelectAllButton", dialog); var deselectAllButton = new ButtonTester("DeselectAllButton", dialog); var generateButton = new ButtonTester("DoForSelectedButton", dialog); var cancelButton = new ButtonTester("CustomCancelButton", dialog); Assert.AreEqual("Selecteer alles", selectAllButton.Text); Assert.AreEqual("Deselecteer alles", deselectAllButton.Text); Assert.AreEqual("Genereren", generateButton.Text); Assert.AreEqual("Annuleren", cancelButton.Text); var semiProbabilisticCheckBox = new CheckBoxTester("SemiProbabilisticCheckBox", dialog); var probabilisticCheckBox = new CheckBoxTester("ProbabilisticCheckBox", dialog); Assert.AreEqual("Semi-probabilistische toets", semiProbabilisticCheckBox.Text); Assert.IsTrue(semiProbabilisticCheckBox.Checked); Assert.AreEqual("Probabilistische toets", probabilisticCheckBox.Text); Assert.IsFalse(probabilisticCheckBox.Checked); } }
public void CheckUnCheck() { CheckBoxTestForm form = new CheckBoxTestForm(); form.Show(); TestWriter writer = new TestWriter(form); Assert.AreEqual("", writer.Test); CheckBoxTester checkBox = new CheckBoxTester("myCheckBox", form); checkBox.Click(); checkBox.Click(); Assert.AreEqual( @"[Test] public void Test() { CheckBoxTester myCheckBox = new CheckBoxTester(""myCheckBox""); myCheckBox.Check(); myCheckBox.UnCheck(); }", writer.Test); }
public void TestAnalysisAttributes() { // At the moment the initial state is unknown so we make a relative test TFrmSetupAnalysisTypes frmAnalysistypes = new TFrmSetupAnalysisTypes(null); frmAnalysistypes.LedgerNumber = FLedgerNumber; frmAnalysistypes.Show(); // Tests schould be repeateable but at the moment we make only a relative test // Press the new Button for the types String randomNewValueString = RandomString(); ButtonTester btnNewType = new ButtonTester("btnNewType"); btnNewType.Click(); TextBoxTester txtDetailAnalysisTypeCode = new TextBoxTester("txtDetailAnalysisTypeCode"); txtDetailAnalysisTypeCode.Properties.Text = randomNewValueString; TextBoxTester txtDetailAnalysisTypeDescription = new TextBoxTester("txtDetailAnalysisTypeDescription"); txtDetailAnalysisTypeDescription.Properties.Text = "Description for " + randomNewValueString; // Press the new Button for the values ButtonTester btnNewValue = new ButtonTester("btnNew"); btnNewValue.Click(); TextBoxTester txtDetailAnalysisValue = new TextBoxTester("txtDetailAnalysisValue"); txtDetailAnalysisValue.Properties.Text = randomNewValueString + "-1"; btnNewValue.Click(); txtDetailAnalysisValue.Properties.Text = randomNewValueString + "-2"; CheckBoxTester chkDetailActive = new CheckBoxTester("chkDetailActive"); Assert.IsTrue(chkDetailActive.Checked, "Active not set as default!"); chkDetailActive.Properties.Checked = false; ToolStripButtonTester btnSave = new ToolStripButtonTester("tbbSave"); // and save everything btnSave.Click(); // Press the delete Button for the values ButtonTester btnDeleteValue = new ButtonTester("ucoValues.btnDelete"); ModalFormHandler = delegate(string name, IntPtr hWnd, Form form) { MessageBoxTester tester = new MessageBoxTester(hWnd); Assert.AreEqual("Confirm Delete", tester.Title); tester.SendCommand(MessageBoxTester.Command.Yes); }; btnDeleteValue.Click(); ModalFormHandler = delegate(string name, IntPtr hWnd, Form form) { MessageBoxTester tester = new MessageBoxTester(hWnd); Assert.AreEqual("Confirm Delete", tester.Title); tester.SendCommand(MessageBoxTester.Command.Yes); }; btnDeleteValue.Click(); // Press the delete Button for the types // TODO: AmbigousNameException. Should we implement this.btnDelete in NUnitForms? ButtonTester btnDeleteType = new ButtonTester("btnDelete"); ModalFormHandler = delegate(string name, IntPtr hWnd, Form form) { MessageBoxTester tester = new MessageBoxTester(hWnd); Assert.AreEqual("Confirm Delete", tester.Title); tester.SendCommand(MessageBoxTester.Command.Yes); }; btnDeleteType.Click(); btnSave.Click(); }
public void TestImportExportGLBatch() { // create two test batches, with some strange figures, to test problem with double values // export the 2 test batches, with summarize option // compare the exported text file string TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/lib/MFinance/GLForm/TestData/BatchImportFloatTest.csv"; TestFile = Path.GetFullPath(TestFile); Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile); TFrmGLBatch frmBatch = new TFrmGLBatch(null); frmBatch.LedgerNumber = FLedgerNumber; frmBatch.Show(); ModalFormHandler = delegate(string name, IntPtr hWnd, Form form) { OpenFileDialogTester tester = new OpenFileDialogTester(hWnd); ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2) { TDlgSelectCSVSeparatorTester tester2 = new TDlgSelectCSVSeparatorTester(hWnd2); TextBoxTester txtDateFormat = new TextBoxTester("txtDateFormat"); txtDateFormat.Properties.Text = "MM/dd/yyyy"; RadioButtonTester rbtSemicolon = new RadioButtonTester("rbtSemicolon"); rbtSemicolon.Properties.Checked = true; ButtonTester btnOK = new ButtonTester("btnOK", tester2.Properties.Name); btnOK.Click(); }; tester.OpenFile(TestFile); }; ToolStripButtonTester btnImport = new ToolStripButtonTester("tbbImportBatches"); btnImport.Click(); ToolStripButtonTester btnSave = new ToolStripButtonTester("tbbSave"); Assert.IsTrue(btnSave.Properties.Enabled, "Save button has not been activated"); btnSave.Click(); // go to Journal tab TabControlTester tabGLBatch = new TabControlTester("tabGLBatch"); tabGLBatch.SelectTab(1); TextBoxTester txtBatchNumber = new TextBoxTester("ucoJournals.txtBatchNumber"); // get the batch number from the journal tab int ImportedBatchNumber = Convert.ToInt32(txtBatchNumber.Properties.Text); TFrmGLBatchExport frmBatchExport = new TFrmGLBatchExport(null); frmBatch.Close(); // export that batch, summarize the transactions // compare the result with the expected file frmBatchExport.LedgerNumber = FLedgerNumber; frmBatchExport.Show(); CheckBoxTester chkIncludeUnposted = new CheckBoxTester("chkIncludeUnposted"); chkIncludeUnposted.Properties.Checked = true; RadioButtonTester rbtSummary = new RadioButtonTester("rbtSummary"); rbtSummary.Properties.Checked = false; RadioButtonTester rbtBatchNumberSelection = new RadioButtonTester("rbtBatchNumberSelection"); rbtBatchNumberSelection.Properties.Checked = true; TextBoxTester txtFilename = new TextBoxTester("txtFilename"); TTxtNumericTextBoxTester txtBatchNumberStart = new TTxtNumericTextBoxTester("txtBatchNumberStart"); txtBatchNumberStart.Properties.NumberValueInt = ImportedBatchNumber; TTxtNumericTextBoxTester txtBatchNumberEnd = new TTxtNumericTextBoxTester("txtBatchNumberEnd"); txtBatchNumberEnd.Properties.NumberValueInt = ImportedBatchNumber; // Test simple export of batches, no summary TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/MFinance/GLForm/TestData/BatchExportFloatTest.csv"; TestFile = Path.GetFullPath(TestFile); Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile); txtFilename.Properties.Text = TestFile + ".new"; ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2) { MessageBoxTester tester2 = new MessageBoxTester(hWnd2); // Assert.AreEqual("Success", tester.Title); tester2.SendCommand(MessageBoxTester.Command.OK); }; frmBatchExport.ExportBatches(false); Assert.AreEqual(true, TTextFile.SameContent(TestFile, TestFile + ".new"), "the files should be the same: " + TestFile); System.IO.File.Delete(TestFile + ".new"); // Test export of batches, summarizing the transactions TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/MFinance/GLForm/TestData/BatchExportFloatTestSummary.csv"; TestFile = Path.GetFullPath(TestFile); Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile); txtFilename.Properties.Text = TestFile + ".new"; rbtSummary.Properties.Checked = true; ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2) { MessageBoxTester tester2 = new MessageBoxTester(hWnd2); // Assert.AreEqual("Success", tester.Title); tester2.SendCommand(MessageBoxTester.Command.OK); }; frmBatchExport.ExportBatches(false); Assert.AreEqual(true, TTextFile.SameContent(TestFile, TestFile + ".new"), "the files should be the same: " + TestFile); System.IO.File.Delete(TestFile + ".new"); frmBatchExport.Close(); }
public static void CheckBox(string name, Form form, bool value) { var chk = new CheckBoxTester(name, form); chk.Properties.Checked = value; }
public override void Setup() { new CheckBoxTestForm().Show(); checkBox = new CheckBoxTester("myCheckBox"); label = new LabelTester("myLabel"); }