예제 #1
0
        public void UpdateCityTests()
        {
            //Arrange
            CitySqlDAO   dao          = new CitySqlDAO(ConnectionString);
            IList <City> cities       = dao.GetCitiesByCountryCode("USA");
            City         cityToUpdate = cities[0];

            //Act
            cityToUpdate.Population = 5;
            dao.UpdateCity(cityToUpdate);

            //Assert
            Assert.AreEqual(5, cityToUpdate.Population); //THIS TEST IS ONLY TESTING MEMORY NOT THE DB

            IList <City> updatedCities = dao.GetCitiesByCountryCode("USA");
            City         fromDB        = null;

            foreach (City c in updatedCities)
            {
                if (c.CityId == cityToUpdate.CityId)
                {
                    fromDB = c;
                    break;
                }
            }
            Assert.AreEqual(5, fromDB.Population);
        }