Example #1
0
        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();
        }
Example #3
0
        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();
        }
Example #4
0
        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 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);
        }
Example #6
0
        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)));
            }
        }
Example #7
0
        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)));
            }
        }
Example #8
0
        public void SelectDoesNotExist()
        {
            ListBoxTester myListBox = new ListBoxTester("myListBox");

            myListBox.SetSelected("blah", true);
        }
Example #9
0
 public void SelectDoesNotExist()
 {
     ListBoxTester myListBox = new ListBoxTester("myListBox");
     myListBox.SetSelected("blah", true);
 }
Example #10
0
        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);
        }
Example #11
0
        public void SelectDoesNotExist()
        {
            ListBoxTester myListBox = new ListBoxTester("myListBox");

            Assert.Throws <ArgumentOutOfRangeException>(() => myListBox.SetSelected("blah", true));
        }
Example #12
0
 public void SelectDoesNotExist()
 {
     ListBoxTester myListBox = new ListBoxTester("myListBox");
     Assert.Throws<ArgumentOutOfRangeException>(() => myListBox.SetSelected("blah", true));
 }