Exemplo n.º 1
0
        public void getMaxTemperatureCitiesOnSameTemperatureCity()
        {
            WeatherCheckerData newyork = new WeatherCheckerData("New York", "50.44", "");
            weatherData.Add(newyork);

            List<string> expected = new List<string> { "Dallas",  "New York" };
            Assert.AreEqual(expected, checkWeather.getMaxTemperature(weatherData));
        }
Exemplo n.º 2
0
        public void ParseWeatherJSONWithInvalidCity()
        {
            string jsonString = @"{""message"":""Error: Not found city"",""cod"":""404""}";

            var expected = new WeatherCheckerData( new Exception("Error: Not found city Houston"));
            var actual = weatherService.parseWeatherJSON(jsonString, "Houston");

            Assert.AreEqual(expected.Error.Message, actual.Error.Message);
        }
Exemplo n.º 3
0
        public void ParseWeatherJSONReturnCorrectOutput()
        {
            string jsonString = @"{""coord"":{""lon"":-95.37,""lat"":29.76},
                                ""sys"":{""message"":0.2941,""country"":""United States of America"",""sunrise"":1426077316,""sunset"":1426120047},
                                ""weather"":[{""id"":802,""main"":""Clouds"",""description"":""scattered clouds"",""icon"":""03n""}],
                                ""base"":""cmc stations"",""main"":{""temp"":53.06,""temp_min"":53.06,""temp_max"":53.06,""pressure"":1030.03,""sea_level"":1031.73,""grnd_level"":1030.03,""humidity"":94},
                                ""wind"":{""speed"":2.87,""deg"":349.502},""clouds"":{""all"":32},""dt"":1426056462,""id"":4699066,""name"":""Houston"",""cod"":200}";
            
            var expected = new WeatherCheckerData("Houston", "53.06", "Clouds");
            var actual = weatherService.parseWeatherJSON(jsonString, "Houston");

            Assert.AreEqual(expected.City, actual.City);
            Assert.AreEqual(expected.Temperature, actual.Temperature);
            Assert.AreEqual(expected.Condition, actual.Condition);
            Assert.AreEqual(expected.Error, actual.Error);
        }