public void btnSelectWhere_ClickTest() { // Setup mock sqlSelectQuery var dataMock = new Mock <DataHelper>(); DataTable outTable = new DataTable(); outTable.Columns.Add("COLUMN_NAME"); outTable.Rows.Add(new string[] { "1st" }); outTable.Rows.Add(new string[] { "2nd" }); dataMock.Setup(_ => _.sqlSelectQuery(It.IsAny <string>(), It.IsAny <string>())).Returns(outTable); SelectTables selectTablesForm = new SelectTables(dataMock.Object); selectTablesForm.Show(); // Select "1st" from the list box and click the where clause btn ListBoxTester lstSelectColumnsTester = new ListBoxTester("lstSelectColumns"); lstSelectColumnsTester.Select("1st"); ButtonTester btnSelectWhereTester = new ButtonTester("btnSelectWhere"); btnSelectWhereTester.Click(); Assert.AreEqual("HouseholdMembers", selectTablesForm.sqlWhereForm.SelectedTableName); Assert.AreEqual(new string[] { "1st" }, selectTablesForm.sqlWhereForm.SelectedColumns); FormTester custSqlWhereTester = new FormTester("CustSqlWhere"); Assert.DoesNotThrow(new TestDelegate(custSqlWhereTester.Close)); }
public void SingleSelectBox() { Form form = new ListBoxTestForm(); form.Show(); TestWriter writer = new TestWriter(form); Assert.AreEqual("", writer.Test); ListBoxTester myListBox = new ListBoxTester("mySingleSelectBox", form); myListBox.ClearSelected(); myListBox.SetSelected(0, true); //Red myListBox.SetSelected(2, true); //Yellow myListBox.SetSelected(4, true); //Blue myListBox.SetSelected(6, true); //Violet Assert.AreEqual( @"[Test] public void Test() { ListBoxTester mySingleSelectBox = new ListBoxTester(""mySingleSelectBox""); mySingleSelectBox.Select(0); //Can mySingleSelectBox.Select(2); //Select mySingleSelectBox.Select(4); //At mySingleSelectBox.Select(6); //Time }", writer.Test); }
public void PersonListView_GetSelectedListItems_ReturnsCorrectPerson() { // Arrange PersonListView view = new PersonListView(); List <Person> personList = new List <Person>(); personList.Add(PersonObjectMother.GetPerson(TestPeople.Bill)); personList.Add(PersonObjectMother.GetPerson(TestPeople.Ted)); personList.Add(PersonObjectMother.GetPerson(TestPeople.Sue)); ListBoxTester listTester = new ListBoxTester("lbxPeople"); //Act view.SetPersonList(personList); view.Show(); // select second person in listbox listTester.SetSelected(1, true); // Assert Assert.AreEqual(personList[1], view.GetSelectedListItem(), "Correct person not returned"); // Cleanup view.Close(); }
public void ListBoxPropertyAsserts() { ListBoxTester myListBox = new ListBoxTester("myListBox"); Assert.AreEqual(true, myListBox.Properties.Visible); Assert.IsNull(myListBox.Properties.SelectedItem); Assert.AreEqual(SelectionMode.MultiExtended, myListBox.Properties.SelectionMode); }
public void SelectItem() { Form form = new ListBoxTestForm(); form.Show(); TestWriter writer = new TestWriter(form); Assert.AreEqual("", writer.Test); ListBoxTester myListBox = new ListBoxTester("myListBox", form); myListBox.Select(0); Assert.AreEqual( @"[Test] public void Test() { ListBoxTester myListBox = new ListBoxTester(""myListBox""); myListBox.ClearSelected(); myListBox.SetSelected(0, True); //Red }", writer.Test); }
public void PersonListView_SetPersonList_DisplaysCorrectPeople() { // Arrange FakePersonListPresenter presenter = new FakePersonListPresenter(); ClientServiceLocator.PersonListPresenter = presenter; PersonListView view = new PersonListView(); List <Person> personList = new List <Person>(); personList.Add(PersonObjectMother.GetPerson(TestPeople.Bill)); personList.Add(PersonObjectMother.GetPerson(TestPeople.Ted)); view.Show(); ListBoxTester listTester = new ListBoxTester("lbxPeople"); //Act view.SetPersonList(personList); // Assert Assert.AreEqual(2, listTester.Properties.Items.Count, "Incorretc number of people in ListBox"); Assert.Contains(personList[0], listTester.Properties.Items, "Person 0 not found in list"); Assert.Contains(personList[1], listTester.Properties.Items, "Person 1 not found in list"); // Cleanup view.Close(); }
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 ListBoxSelection() { LabelTester myLabel = new LabelTester("myLabel"); ListBoxTester myListBox = new ListBoxTester("myListBox"); myListBox.ClearSelected(); myListBox.Select(rainbowArray[0]); Assert.AreEqual(rainbowArray[0], myLabel.Text); }
public void lstSelectTable_SelectedValueChangedTest() { // Test it is correct when the form loads var dataMock = new Mock <DataHelper>(); // Setup Sql query return value string[] columnsList = new string[] { "1st", "2nd" }; DataTable outTable = new DataTable(); outTable.Columns.Add("COLUMN_NAME"); foreach (string col in columnsList) { outTable.Rows.Add(new string[] { col }); } // Mock the sqlSelectQuery string tableName = "HouseholdMembers"; string queryString = "SELECT COLUMN_NAME FROM [ClientcardFB3].information_schema.columns WHERE TABLE_NAME = '" + tableName + "'"; dataMock.Setup(_ => _.sqlSelectQuery(It.IsAny <string>(), queryString)).Returns(outTable); // Initialize class SelectTables selectTablesForm = new SelectTables(dataMock.Object); selectTablesForm.Show(); ListBoxTester lstSelectColumnsTester = new ListBoxTester("lstSelectColumns"); string[] columnsListAct = (string[])lstSelectColumnsTester.Properties.DataSource; Assert.AreEqual(columnsList, columnsListAct); //Test it's correct when another value in the list box is selected string[] columnsList2 = new string[] { "3rd", "4th" }; DataTable outTable2 = new DataTable(); outTable2.Columns.Add("COLUMN_NAME"); foreach (string col in columnsList2) { outTable2.Rows.Add(new string[] { col }); } string tableName2 = "Household"; string queryString2 = "SELECT COLUMN_NAME FROM [ClientcardFB3].information_schema.columns WHERE TABLE_NAME = '" + tableName2 + "'"; dataMock.Setup(_ => _.sqlSelectQuery(It.IsAny <string>(), queryString2)).Returns(outTable2); ListBoxTester lstSelectTableTester = new ListBoxTester("lstSelectTable"); lstSelectTableTester.Select(tableName2); columnsListAct = (string[])lstSelectColumnsTester.Properties.DataSource; Assert.AreEqual(columnsList2, columnsListAct); }
public override void Setup() { base.Setup(); m_usernameTextbox = new TextBoxTester("m_usernameTextbox"); m_connectButton = new ButtonTester("m_connectButton"); m_disconnectbutton = new ButtonTester("m_disconnectbutton"); m_sendMsgButton = new ButtonTester("m_sendMsgButton"); m_sendMsgAsyncButton = new ButtonTester("m_sendMsgAsyncButton"); m_connectedLabel = new LabelTester("m_constatus"); m_messageTextbox = new TextBoxTester("m_messageTextbox"); m_messagesTester = new ListBoxTester("m_messages"); m_client = new Client("localhost", 8087, 0); m_chatform = m_client.CreateChatForm(); m_chatform.Show(); m_usernameTextbox.Enter("test"); m_connectButton.Click(); }
public void MutlipleSelection() { Form form = new ListBoxTestForm(); form.Show(); TestWriter writer = new TestWriter(form); Assert.AreEqual("", writer.Test); ListBoxTester myListBox = new ListBoxTester("myListBox", form); myListBox.ClearSelected(); myListBox.SetSelected(0, true); //Red myListBox.SetSelected(2, true); //Yellow myListBox.SetSelected(4, true); //Blue myListBox.SetSelected(6, true); //Violet Assert.AreEqual( @"[Test] public void Test() { ListBoxTester myListBox = new ListBoxTester(""myListBox""); myListBox.ClearSelected(); myListBox.SetSelected(0, True); //Red myListBox.ClearSelected(); myListBox.SetSelected(0, True); //Red myListBox.SetSelected(2, True); //Yellow myListBox.ClearSelected(); myListBox.SetSelected(0, True); //Red myListBox.SetSelected(2, True); //Yellow myListBox.SetSelected(4, True); //Blue myListBox.ClearSelected(); myListBox.SetSelected(0, True); //Red myListBox.SetSelected(2, True); //Yellow myListBox.SetSelected(4, True); //Blue myListBox.SetSelected(6, True); //Violet }", writer.Test); }
public void ListBoxMultiSelection() { ListBoxTester myListBox = new ListBoxTester("myListBox"); string[] alternateColors = new string[] {"Red", "Yellow", "Blue", "Violet"}; StringCollection alternates = new StringCollection(); alternates.AddRange(alternateColors); myListBox.ClearSelected(); foreach(string color in alternates) { myListBox.SetSelected(color, true); } Assert.AreEqual(4, myListBox.Properties.SelectedItems.Count); foreach(object selectedItem in myListBox.Properties.SelectedItems) { Assert.IsTrue(alternates.Contains(Convert.ToString(selectedItem))); } }
public void ListBoxMultiSelection() { ListBoxTester myListBox = new ListBoxTester("myListBox"); string[] alternateColors = new string[] { "Red", "Yellow", "Blue", "Violet" }; StringCollection alternates = new StringCollection(); alternates.AddRange(alternateColors); myListBox.ClearSelected(); foreach (string color in alternates) { myListBox.SetSelected(color, true); } Assert.AreEqual(4, myListBox.Properties.SelectedItems.Count); foreach (object selectedItem in myListBox.Properties.SelectedItems) { Assert.IsTrue(alternates.Contains(Convert.ToString(selectedItem))); } }
public void SelectDoesNotExist() { ListBoxTester myListBox = new ListBoxTester("myListBox"); Assert.Throws<ArgumentOutOfRangeException>(() => myListBox.SetSelected("blah", true)); }
public void SelectDoesNotExist() { ListBoxTester myListBox = new ListBoxTester("myListBox"); myListBox.SetSelected("blah", true); }
public void SelectDoesNotExist() { ListBoxTester myListBox = new ListBoxTester("myListBox"); Assert.Throws <ArgumentOutOfRangeException>(() => myListBox.SetSelected("blah", true)); }