public static Person GetPerson(TestPeople name) { switch (name) { case TestPeople.Ted: return(new Person() { Forename = "Ted", Surname = "Jones", BirthdayDay = 1, BirthdayMonth = 1 }); case TestPeople.Bill: return(new Person() { Forename = "Bill", Surname = "Bailey", BirthdayDay = 31, BirthdayMonth = 12 }); case TestPeople.Sue: return(new Person() { Forename = "Sue", Surname = "Smedley", BirthdayDay = 15, BirthdayMonth = 6 }); default: Debug.Assert(false, "Invalid person selected"); return(null); break; } }
public static Person GetPerson(TestPeople name) { switch (name) { case TestPeople.Ted: return new Person() { Forename = "Ted", Surname = "Jones", BirthdayDay = 1, BirthdayMonth = 1 }; case TestPeople.Bill: return new Person() { Forename = "Bill", Surname = "Bailey", BirthdayDay = 31, BirthdayMonth = 12 }; case TestPeople.Sue: return new Person() { Forename = "Sue", Surname = "Smedley", BirthdayDay = 15, BirthdayMonth = 6 }; default: Debug.Assert(false, "Invalid person selected"); return null; break; } }
public void WhenSearchingPeople(string name, Gender?gender, int pageNum, int pageSize, int resultCount) { // Arrange Mock <IDataStore <Data> > dataStore = new Mock <IDataStore <Data> >(); dataStore.Setup(ds => ds.Get()) .Returns(new Data { places = TestPlaces.GetPlaces(), people = TestPeople.GetPeople() }); PersonSearchService classUnderTest = new PersonSearchService(dataStore.Object); PersonView[] result = null; // Act result = classUnderTest.Search(name, gender.HasValue ? gender.Value : Gender.Male | Gender.Female, pageNum, pageSize); // Assert Assert.IsNotNull(result); Assert.AreEqual(resultCount, result.Length); }
public void WhenSearchingAncestry(string name, Gender?gender, Ancestry ancestry, int resultCount, int[] expectedIds) { // Arrange Mock <IDataStore <Data> > dataStore = new Mock <IDataStore <Data> >(); dataStore.Setup(ds => ds.Get()) .Returns(new Data { places = TestPlaces.GetPlaces(), people = TestPeople.GetPeople() }); PersonSearchService classUnderTest = new PersonSearchService(dataStore.Object); PersonView[] result = null; // Act result = classUnderTest.AncestrySearch(name, gender.HasValue ? gender.Value : Gender.Male | Gender.Female, ancestry); Assert.IsNotNull(result); Assert.AreEqual(resultCount, result.Length); Assert.IsTrue(Enumerable.SequenceEqual(expectedIds, result.Select(p => p.Id))); // Assert }