コード例 #1
0
        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);
        }
コード例 #2
0
        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
        }