예제 #1
0
        public void PersonDetailsPresenter_OkButtonPressedInAddMode_AddsPersonToManager()
        {
            // Arrange
            FakePersonManager  manager = new FakePersonManager();
            IPersonDetailsView view    = new FakePersonDetailsView()
            {
                Forename = "Jed", Surname = "Jetson", BirthdayDay = "29", BirthdayMonth = "2"
            };
            FakeViewFactory factory = new FakeViewFactory(view);

            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager);

            presenter.AddPerson();

            //Act
            presenter.OkButtonPressed();

            //Assert
            Person addedPerson = manager.AddedPerson;

            Assert.IsNotNull(addedPerson, "The person was not added to the repository");
            Assert.AreEqual("Jed", addedPerson.Forename, "Forename not added correctly");
            Assert.AreEqual("Jetson", addedPerson.Surname, "Surname not added correctly");
            Assert.AreEqual(29, addedPerson.BirthdayDay, "BirthdayDay not added correctly");
            Assert.AreEqual(2, addedPerson.BirthdayMonth, "BirthdayMonth not added correctly");
        }
        public void PersonListPresenter_AddButtonPressed_ReloadsPersonList()
        {
            // Arrange
            List <Person> personList = new List <Person>()
            {
                PersonObjectMother.GetPerson(TestPeople.Sue),
                PersonObjectMother.GetPerson(TestPeople.Bill)
            };

            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            FakePersonManager manager = new FakePersonManager();

            manager.PersonList = personList;

            FakePersonListView   listView      = new FakePersonListView();
            IPersonListPresenter listPresenter = new PersonListPresenter(listView, manager);

            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            //Act
            listView.PressAddButton();

            //Assert
            Assert.AreEqual(personList, listView.PersonList, "PersonList in View does not match that from the Manager");
        }
        public void PersonListPresenter_LoadButtonPressed_ShowsWaitCursorWhileDataLoading()
        {
            // Arrange
            List <Person> personList = new List <Person>()
            {
                PersonObjectMother.GetPerson(TestPeople.Ted),
                PersonObjectMother.GetPerson(TestPeople.Sue)
            };

            FakePersonManager manager = new FakePersonManager();

            manager.PersonList = personList;

            FakePersonListView   view      = new FakePersonListView();
            IPersonListPresenter presenter = new PersonListPresenter(view, manager);

            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            DateTime startTime = DateTime.Now;

            //Act
            view.PressLoadButton();

            //Assert
            Assert.Greater(view.WaitCursorSetTime, startTime, "Wait cursor not set after start time");
            Assert.Greater(view.DefaultCursorSetTime, view.WaitCursorSetTime, "Default cursor not set after wait cursor set");
        }
        public void PersonListPresenter_DeleteButtonPressed_DeletesSelectedPersonFromRepository()
        {
            // Arrange
            List <Person> personList = new List <Person>()
            {
                PersonObjectMother.GetPerson(TestPeople.Sue),
                PersonObjectMother.GetPerson(TestPeople.Bill)
            };

            FakePersonManager  manager = new FakePersonManager();
            FakePersonListView view    = new FakePersonListView();

            view.PersonList = personList;

            IPersonListPresenter presenter = new PersonListPresenter(view, manager);

            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            //Act
            view.PressDeleteButton();

            //Assert
            Assert.IsNotNull(manager.DeletedPerson, "Person not deleted from repository");
            Assertions.AssertPeopleAreEqual(personList[0], manager.DeletedPerson);
        }
예제 #5
0
        public void PersonDetailsPresenter_ShowView_ShowsView()
        {
            // Arrange
            FakePersonManager       manager   = new FakePersonManager();
            FakePersonDetailsView   view      = new FakePersonDetailsView();
            FakeViewFactory         factory   = new FakeViewFactory(view);
            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager);

            //Act
            presenter.ShowView(false);

            //Assert
            Assert.IsTrue(view.FormShown, "View not shown");
        }
예제 #6
0
        public void PersonDetailsPresenter_AddPerson_SetsViewTitle()
        {
            // Arrange
            FakePersonManager       manager   = new FakePersonManager();
            FakePersonDetailsView   view      = new FakePersonDetailsView();
            FakeViewFactory         factory   = new FakeViewFactory(view);
            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager);

            //Act
            presenter.AddPerson();

            //Assert
            Assert.AreEqual("Add Person", view.Title, "Title not set in view");
        }
        public void PersonListPresenter_AddButtonPressed_CallsAddPerson()
        {
            // Arrange
            FakePersonManager manager = new FakePersonManager();
            FakePersonListView listView = new FakePersonListView();
            IPersonListPresenter listPresenter = new PersonListPresenter(listView, manager);
            FakePersonDetailsPresenter detailsPresenter = new FakePersonDetailsPresenter();
            ClientServiceLocator.PersonDetailsPresenter = detailsPresenter;

            //Act
            listView.PressAddButton();

            //Assert
            Assert.IsTrue(detailsPresenter.AddPersonCalled, "Add not called on Presenter");
        }
        public void PersonListPresenter_DeleteButtonPressed_GetsSelectedPersonFromView()
        {
            // Arrange
            FakePersonManager    manager   = new FakePersonManager();
            FakePersonListView   view      = new FakePersonListView();
            IPersonListPresenter presenter = new PersonListPresenter(view, manager);

            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            //Act
            view.PressDeleteButton();

            //Assert
            Assert.IsTrue(view.GetSeletedListItemCalled, "GetSeletedListItem() not called");
        }
        public void PersonListPresenter_DeleteButtonPressed_GivesWarningIfNoPersonSelected()
        {
            // Arrange
            FakePersonManager  manager  = new FakePersonManager();
            FakePersonListView listView = new FakePersonListView();

            IPersonListPresenter listPresenter = new PersonListPresenter(listView, manager);

            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            //Act
            listView.PressDeleteButton();

            //Assert
            Assert.AreEqual("Please select a person to delete", listView.WarningMessage, "Warning message not set correctly");
        }
        public void PersonListPresenter_AddButtonPressed_CallsAddPerson()
        {
            // Arrange
            FakePersonManager          manager          = new FakePersonManager();
            FakePersonListView         listView         = new FakePersonListView();
            IPersonListPresenter       listPresenter    = new PersonListPresenter(listView, manager);
            FakePersonDetailsPresenter detailsPresenter = new FakePersonDetailsPresenter();

            ClientServiceLocator.PersonDetailsPresenter = detailsPresenter;

            //Act
            listView.PressAddButton();

            //Assert
            Assert.IsTrue(detailsPresenter.AddPersonCalled, "Add not called on Presenter");
        }
예제 #11
0
        public void PersonDetailsPresenter_EditPerson_PassesCorrectDetailsToView()
        {
            // Arrange
            FakePersonManager       manager   = new FakePersonManager();
            FakePersonDetailsView   view      = new FakePersonDetailsView();
            FakeViewFactory         factory   = new FakeViewFactory(view);
            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager);

            //Act
            presenter.EditPerson(PersonObjectMother.GetPerson(TestPeople.Ted));

            //Assert
            Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).Forename, view.Forename, "Forename not set in view");
            Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).Surname, view.Surname, "Surname not set in view");
            Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).BirthdayDay.ToString(), view.BirthdayDay, "BirthdayDay not set in view");
            Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).BirthdayMonth.ToString(), view.BirthdayMonth, "BirthdayMonth not set in view");
        }
        public void PersonListPresenter_LoadButtonPressed_SetsPersonList()
        {
            // Arrange
            List<Person> personList = new List<Person>(){PersonObjectMother.GetPerson(TestPeople.Ted),
                                                         PersonObjectMother.GetPerson(TestPeople.Sue)};

            FakePersonManager manager = new FakePersonManager();
            manager.PersonList = personList;

            FakePersonListView view = new FakePersonListView();
            IPersonListPresenter presenter = new PersonListPresenter(view, manager);
            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            //Act
            view.PressLoadButton();

            //Assert
            Assert.AreEqual(personList, view.PersonList, "PersonList in View does not match that from the Manager");
        }
예제 #13
0
        public void PersonDetailsPresenter_OkButtonPressedInEditMode_UpdatesPersonInManager()
        {
            // Arrange
            FakePersonManager       manager   = new FakePersonManager();
            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(new FakeViewFactory(), manager);

            Person p = PersonObjectMother.GetPerson(TestPeople.Sue);

            presenter.EditPerson(p);

            //Act
            presenter.OkButtonPressed();

            //Assert
            Person updatedPerson = manager.UpdatedPerson;

            Assert.IsNotNull(updatedPerson, "The person was not updated in the manager");

            Assertions.AssertPeopleAreEqual(p, updatedPerson);
        }
        public void PersonDetailsPresenter_OkButtonPressedInAddMode_AddsPersonToManager()
        {
            // Arrange
            FakePersonManager manager = new FakePersonManager();
            IPersonDetailsView view = new FakePersonDetailsView() { Forename = "Jed", Surname = "Jetson", BirthdayDay = "29", BirthdayMonth = "2" };
            FakeViewFactory factory = new FakeViewFactory(view);

            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager);
            presenter.AddPerson();

            //Act
            presenter.OkButtonPressed();

            //Assert
            Person addedPerson = manager.AddedPerson;
            Assert.IsNotNull(addedPerson, "The person was not added to the repository");
            Assert.AreEqual("Jed", addedPerson.Forename, "Forename not added correctly");
            Assert.AreEqual("Jetson", addedPerson.Surname, "Surname not added correctly");
            Assert.AreEqual(29, addedPerson.BirthdayDay, "BirthdayDay not added correctly");
            Assert.AreEqual(2, addedPerson.BirthdayMonth, "BirthdayMonth not added correctly");
        }
        public void PersonListPresenter_EditButtonPressed_CallsShowView()
        {
            // Arrange
            FakePersonManager  manager  = new FakePersonManager();
            FakePersonListView listView = new FakePersonListView();

            listView.PersonList = new List <Person>()
            {
                PersonObjectMother.GetPerson(TestPeople.Bill)
            };
            IPersonListPresenter       listPresenter    = new PersonListPresenter(listView, manager);
            FakePersonDetailsPresenter detailsPresenter = new FakePersonDetailsPresenter();

            ClientServiceLocator.PersonDetailsPresenter = detailsPresenter;

            //Act
            listView.PressEditButton();

            //Assert
            Assert.IsTrue(detailsPresenter.ShowViewCalled, "Show not called on Presenter");
        }
        public void PersonListPresenter_LoadButtonPressed_ShowsWaitCursorWhileDataLoading()
        {
            // Arrange
            List<Person> personList = new List<Person>(){PersonObjectMother.GetPerson(TestPeople.Ted),
                                                         PersonObjectMother.GetPerson(TestPeople.Sue)};

            FakePersonManager manager = new FakePersonManager();
            manager.PersonList = personList;

            FakePersonListView view = new FakePersonListView();
            IPersonListPresenter presenter = new PersonListPresenter(view, manager);
            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            DateTime startTime = DateTime.Now;

            //Act
            view.PressLoadButton();

            //Assert
            Assert.Greater(view.WaitCursorSetTime, startTime, "Wait cursor not set after start time");
            Assert.Greater(view.DefaultCursorSetTime, view.WaitCursorSetTime, "Default cursor not set after wait cursor set");
        }
        public void PersonListPresenter_EditButtonPressed_PassesDetailsToPersonDetailsPresenter()
        {
            // Arrange
            List <Person> personList = new List <Person>()
            {
                PersonObjectMother.GetPerson(TestPeople.Ted)
            };

            FakePersonManager  manager  = new FakePersonManager();
            FakePersonListView listView = new FakePersonListView();

            listView.SetPersonList(personList);
            IPersonListPresenter       listPresenter    = new PersonListPresenter(listView, manager);
            FakePersonDetailsPresenter detailsPresenter = new FakePersonDetailsPresenter();

            ClientServiceLocator.PersonDetailsPresenter = detailsPresenter;

            //Act
            listView.PressEditButton();

            //Assert
            Assertions.AssertPeopleAreEqual(PersonObjectMother.GetPerson(TestPeople.Ted), detailsPresenter.EditedPerson);
        }
        public void PersonListPresenter_LoadButtonPressed_SetsPersonList()
        {
            // Arrange
            List <Person> personList = new List <Person>()
            {
                PersonObjectMother.GetPerson(TestPeople.Ted),
                PersonObjectMother.GetPerson(TestPeople.Sue)
            };

            FakePersonManager manager = new FakePersonManager();

            manager.PersonList = personList;

            FakePersonListView   view      = new FakePersonListView();
            IPersonListPresenter presenter = new PersonListPresenter(view, manager);

            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            //Act
            view.PressLoadButton();

            //Assert
            Assert.AreEqual(personList, view.PersonList, "PersonList in View does not match that from the Manager");
        }
        public void PersonDetailsPresenter_AddPerson_SetsViewTitle()
        {
            // Arrange
            FakePersonManager manager = new FakePersonManager();
            FakePersonDetailsView view = new FakePersonDetailsView();
            FakeViewFactory factory = new FakeViewFactory(view);
            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager);

            //Act
            presenter.AddPerson();

            //Assert
            Assert.AreEqual("Add Person", view.Title, "Title not set in view");
        }
        public void PersonListPresenter_EditButtonPressed_PassesDetailsToPersonDetailsPresenter()
        {
            // Arrange
            List<Person> personList = new List<Person>() { PersonObjectMother.GetPerson(TestPeople.Ted) };

            FakePersonManager manager = new FakePersonManager();
            FakePersonListView listView = new FakePersonListView();
            listView.SetPersonList(personList);
            IPersonListPresenter listPresenter = new PersonListPresenter(listView, manager);
            FakePersonDetailsPresenter detailsPresenter = new FakePersonDetailsPresenter();
            ClientServiceLocator.PersonDetailsPresenter = detailsPresenter;

            //Act
            listView.PressEditButton();

            //Assert
            Assertions.AssertPeopleAreEqual(PersonObjectMother.GetPerson(TestPeople.Ted), detailsPresenter.EditedPerson);
        }
        public void PersonListPresenter_DeleteButtonPressed_GivesWarningIfNoPersonSelected()
        {
            // Arrange
            FakePersonManager manager = new FakePersonManager();
            FakePersonListView listView = new FakePersonListView();

            IPersonListPresenter listPresenter = new PersonListPresenter(listView, manager);
            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            //Act
            listView.PressDeleteButton();

            //Assert
            Assert.AreEqual("Please select a person to delete", listView.WarningMessage, "Warning message not set correctly");
        }
        public void PersonListPresenter_AddButtonPressed_ReloadsPersonList()
        {
            // Arrange
            List<Person> personList = new List<Person>() { PersonObjectMother.GetPerson(TestPeople.Sue),
                                                           PersonObjectMother.GetPerson(TestPeople.Bill)};

            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            FakePersonManager manager = new FakePersonManager();
            manager.PersonList = personList;

            FakePersonListView listView = new FakePersonListView();
            IPersonListPresenter listPresenter = new PersonListPresenter(listView, manager);
            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            //Act
            listView.PressAddButton();

            //Assert
            Assert.AreEqual(personList, listView.PersonList, "PersonList in View does not match that from the Manager");
        }
        public void PersonDetailsPresenter_EditPerson_PassesCorrectDetailsToView()
        {
            // Arrange
            FakePersonManager manager = new FakePersonManager();
            FakePersonDetailsView view = new FakePersonDetailsView();
            FakeViewFactory factory = new FakeViewFactory(view);
            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager);

            //Act
            presenter.EditPerson(PersonObjectMother.GetPerson(TestPeople.Ted));

            //Assert
            Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).Forename, view.Forename, "Forename not set in view");
            Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).Surname, view.Surname, "Surname not set in view");
            Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).BirthdayDay.ToString(), view.BirthdayDay, "BirthdayDay not set in view");
            Assert.AreEqual(PersonObjectMother.GetPerson(TestPeople.Ted).BirthdayMonth.ToString(), view.BirthdayMonth, "BirthdayMonth not set in view");
        }
        public void PersonListPresenter_EditButtonPressed_CallsShowView()
        {
            // Arrange
            FakePersonManager manager = new FakePersonManager();
            FakePersonListView listView = new FakePersonListView();
            listView.PersonList = new List<Person>() { PersonObjectMother.GetPerson(TestPeople.Bill) };
            IPersonListPresenter listPresenter = new PersonListPresenter(listView, manager);
            FakePersonDetailsPresenter detailsPresenter = new FakePersonDetailsPresenter();
            ClientServiceLocator.PersonDetailsPresenter = detailsPresenter;

            //Act
            listView.PressEditButton();

            //Assert
            Assert.IsTrue(detailsPresenter.ShowViewCalled, "Show not called on Presenter");
        }
        public void PersonDetailsPresenter_ShowView_ShowsView()
        {
            // Arrange
            FakePersonManager manager = new FakePersonManager();
            FakePersonDetailsView view = new FakePersonDetailsView();
            FakeViewFactory factory = new FakeViewFactory(view);
            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(factory, manager);

            //Act
            presenter.ShowView(false);

            //Assert
            Assert.IsTrue(view.FormShown, "View not shown");
        }
        public void PersonListPresenter_DeleteButtonPressed_DeletesSelectedPersonFromRepository()
        {
            // Arrange
            List<Person> personList = new List<Person>() { PersonObjectMother.GetPerson(TestPeople.Sue),
                                                           PersonObjectMother.GetPerson(TestPeople.Bill)};

            FakePersonManager manager = new FakePersonManager();
            FakePersonListView view = new FakePersonListView();
            view.PersonList = personList;

            IPersonListPresenter presenter = new PersonListPresenter(view, manager);
            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            //Act
            view.PressDeleteButton();

            //Assert
            Assert.IsNotNull(manager.DeletedPerson, "Person not deleted from repository");
            Assertions.AssertPeopleAreEqual(personList[0], manager.DeletedPerson);
        }
        public void PersonDetailsPresenter_OkButtonPressedInEditMode_UpdatesPersonInManager()
        {
            // Arrange
            FakePersonManager manager = new FakePersonManager();
            IPersonDetailsPresenter presenter = new PersonDetailsPresenter(new FakeViewFactory(), manager);

            Person p = PersonObjectMother.GetPerson(TestPeople.Sue);
            presenter.EditPerson(p);

            //Act
            presenter.OkButtonPressed();

            //Assert
            Person updatedPerson = manager.UpdatedPerson;
            Assert.IsNotNull(updatedPerson, "The person was not updated in the manager");

            Assertions.AssertPeopleAreEqual(p, updatedPerson);
        }
        public void PersonListPresenter_DeleteButtonPressed_GetsSelectedPersonFromView()
        {
            // Arrange
            FakePersonManager manager = new FakePersonManager();
            FakePersonListView view = new FakePersonListView();
            IPersonListPresenter presenter = new PersonListPresenter(view, manager);
            ClientServiceLocator.PersonDetailsPresenter = new FakePersonDetailsPresenter();

            //Act
            view.PressDeleteButton();

            //Assert
            Assert.IsTrue(view.GetSeletedListItemCalled, "GetSeletedListItem() not called");
        }