public void PersonListView_EditButtonPressed_FiresEvent()
        {
            // Arrange
            bool EditButtonEventFired = false;
            PersonListView view = new PersonListView();
            view.EditButtonPressed += new ViewEvent(delegate { EditButtonEventFired = true; });
            view.Show();
            ButtonTester loadTester = new ButtonTester("btnEdit");

            //Act
            loadTester.Click();

            // Assert
            Assert.IsTrue(EditButtonEventFired, "EditButtonPressed doesn't fire event");

            // Cleanup
            view.Close();
        }
        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 PersonListView_ShowDefaultCursor_ShowsDefaultCursor()
        {
            //Arrange 
            ClientServiceLocator.PersonListPresenter = new FakePersonListPresenter();
            PersonListView view = new PersonListView();
            view.Show();
            FormTester viewTest = new FormTester("PersonListView");

            // Act
            view.Cursor = Cursors.Cross; // ensure set to something else before test
            view.SetDefaultCursor();

            // Assert
            Assert.AreEqual(Cursors.Default, viewTest.Properties.Cursor, "Default cursor not shown");

            // Cleanup
            view.Close();
        }
        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();
        }