Exemple #1
0
        public void ThrowEntityDoesNotExistException_WhenCityDoesNotExist()
        {
            //Act
            var cityService = new CityServices(unitOfWork.Object);

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

            //Assert
            Assert.ThrowsException <EntityDoesntExistException>(() => cityService.GetID("NonExistingCity"));
        }
Exemple #2
0
        public void ReturnCorrectCityId_WhenCityExists()
        {
            //Arrange
            unitOfWork.Setup(x => x.Cities)
            .Returns(cityRepoMock.Object);

            cityRepoMock.Setup(repo => repo.AllAndDeleted())
            .Returns(resultFromCityRepo.AsQueryable());

            //Act
            var cityService = new CityServices(unitOfWork.Object);
            var result      = cityService.GetID(city.Name);

            //Assert
            Assert.AreEqual(city.Id, result);
        }