public void UnitAddCity_When_CityExistsInList_Then_CityCountLeftConstant(string name) { var city = new City { Id = 1, Name = name }; cities.Add(city); controller.Add(city.Name); var count = cities.Where(c => c.Name == city.Name).Count(); cities.Remove(city); Assert.AreEqual(1, count); }
public async Task Add_AddGivenCity_ReturnTrue() { var city = Mock.Of <City>(city => city.Id == 1 && city.CityName == "Hyderabad" && city.Country == "India"); _cityRepository.Setup(city => city.Save(It.IsAny <City>())).ReturnsAsync(true); var result = await _cityController.Add(city); Assert.True(result); }
public void IntegrationAddCity_When_CityExistsInList_Then_CityCountLeftConstant(string name) { var city = new City { Name = name }; unitOfWork.Cities.Insert(city); unitOfWork.SaveChanges(); var foundCity = unitOfWork.Cities.Get(c => c.Name == city.Name); controller.Add(city.Name); var count = unitOfWork.Cities.GetAll().Where(c => c.Name == city.Name).Count(); unitOfWork.Cities.Delete(foundCity); unitOfWork.SaveChanges(); Assert.AreEqual(1, count); }