Ejemplo n.º 1
0
        public async Task <IHttpActionResult> GetCityAsync(int cityId)
        {
            City city = await cq.GetCityAsync(cityId);

            if (city == null)
            {
                return(NotFound());
            }

            return(Ok(city));
        }
Ejemplo n.º 2
0
        public async Task City_Not_Found()
        {
            //Arrange
            string cityName = "Muffin";

            cityQueries = new CityQueries(context.Object);

            //Act
            var result = await cityQueries.GetCityAsync(cityName);

            //Assert
            Assert.IsNull(result);
        }
Ejemplo n.º 3
0
        public async Task Get_City_By_Name()
        {
            //Arrange
            string cityName = "Pie";

            cityQueries = new CityQueries(context.Object);

            //Act
            var result = await cityQueries.GetCityAsync(cityName);

            var state = cities.Where(w => w.Name == cityName).FirstOrDefault();

            //Assert
            Assert.AreEqual(state.StateId, result.StateId);
            Assert.AreEqual(state.Name, result.Name);
        }
Ejemplo n.º 4
0
        public async Task Get_State_By_Id()
        {
            //Arrange
            int cityId = 2;

            cityQueries = new CityQueries(context.Object);

            //Act
            var result = await cityQueries.GetCityAsync(cityId);

            var state = cities.Where(w => w.CityId == cityId).FirstOrDefault();

            //Assert
            Assert.AreEqual(state.CityId, result.CityId);
            Assert.AreEqual(state.Name, result.Name);
        }