コード例 #1
0
        public void ReturnCollectionOfCities()
        {
            //Arrange
            var resultFromCityRepo = new List <City>()
            {
                firstCityMock.Object, secondCityMock.Object
            };
            var expectedList = new List <string>()
            {
                "TestCityOne", "TestCityTwo"
            };

            unitOfWork.Setup(x => x.Cities).Returns(cityRepoMock.Object);
            cityRepoMock.Setup(repo => repo.All()).Returns(resultFromCityRepo.AsQueryable());

            //Act
            var cityService = new CityServices(unitOfWork.Object);
            var result      = cityService.GetCityNames();

            //Assert
            CollectionAssert.AreEquivalent(expectedList, result.ToList());
        }