Example #1
0
        public void TestGetWeatherForInValidCityAPI()
        {  //Arrange
            MockWeatherDataService mockService = new MockWeatherDataService();
            WeatherDataController  service     = new WeatherDataController(mockService);

            //Act
            var result   = service.GetWeather("Australia", "Tokyo") as NotFoundObjectResult;
            var response = result.Value as string;

            //Asset
            Assert.AreEqual("Tokyo City does not exist in Australia", response);
        }
Example #2
0
        public void TestGetWeatherAPI()
        {  //Arrange
            MockWeatherDataService mockService = new MockWeatherDataService();
            WeatherDataController  service     = new WeatherDataController(mockService);
            CityWeatherData        sydneyData  = new CityWeatherData {
                Wind = "Strong", Pressure = "1008 hpa", SkyCondition = "Clear", Temperature = 31.3, Time = DateTime.Now.ToString(), Visibility = "Good"
            };

            //Act
            var result   = service.GetWeather("Australia", "Sydney") as OkObjectResult;
            var response = result.Value as CityWeatherData;

            //Asset
            Assert.AreEqual(sydneyData, response);
        }