public void PersonManager_GetAll_ReturnsListFromRepository()
        {
            // Arrange
            List<Person> personList = new List<Person>();

            personList.Add(new Person() { Id = 1, Forename = "Jimmy", Surname = "Choo", BirthdayDay = 1, BirthdayMonth = 1 });
            personList.Add(new Person() { Id = 2, Forename = "Sammy", Surname = "Davis", BirthdayDay = 31, BirthdayMonth = 12 });
            personList.Add(new Person() { Id = 3, Forename = "Patsy", Surname = "Kensit", BirthdayDay = 1, BirthdayMonth = 1 });

            FakePersonRepository mockRepository = new FakePersonRepository();
            mockRepository.PersonList = personList;

            PersonManager manager = new PersonManager(mockRepository);

            // Act
            ICollection<Person> managerPeople = manager.GetAllPeople();

            // Assert
            Assert.AreEqual(3, managerPeople.Count, "The wrong number of people were loaded");
            foreach (Person p in managerPeople)
            {
                Person testPerson = (from person in personList
                                    where person.Id == p.Id
                                    select person).Single();

                Assertions.AssertPeopleAreEqual(p, testPerson);
            }
        }
 public static void SetupServiceLocator()
 {
     IPersonManager manager = new PersonManager(new PersonRepository());
     IViewFactory viewFactory = new ViewFactory();
     IPersonDetailsPresenter detailsPresenter = new PersonDetailsPresenter(viewFactory, manager);
     IPersonListView listView = new PersonListView();
     IPersonListPresenter listPresenter = new PersonListPresenter(listView, manager);
     ClientServiceLocator.PersonDetailsPresenter = detailsPresenter;
     ClientServiceLocator.PersonListPresenter = listPresenter;
 }
        public void PersonManager_DeletePerson_RemovesFromRepository()
        {
            //Arrange
            FakePersonRepository mockRepository = new FakePersonRepository();
            PersonManager manager = new PersonManager(mockRepository);

            Person p = new Person() { Id = 1, Forename = "Ted", Surname = "Smith", BirthdayDay = 1, BirthdayMonth = 12 };

            //Act 
            manager.DeletePerson(p);

            //Assert
            Assert.IsNotNull(mockRepository.DeletedPerson, "Person not removed from repository");
            Assertions.AssertPeopleAreEqual(p, mockRepository.DeletedPerson);
        }
        public void PersonManager_UpdatePerson_UpdatesPersonInRepository()
        {
            //Arrange
            FakePersonRepository mockRepository = new FakePersonRepository();
            PersonManager manager = new PersonManager(mockRepository);

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

            //Act 
            manager.UpdatePerson(p);

            //Assert
            Assert.IsNotNull(mockRepository.UpdatedPerson, "Person not updated in repository");
            Assertions.AssertPeopleAreEqual(p, mockRepository.UpdatedPerson);
        }