Exemple #1
0
        public void GetAPIKeyShouldReturnCorrectKey()
        {
            //Arrange
            OpenWeaherAPI api = new OpenWeaherAPI();
            //Act
            string currentKey = api.GetAPIKey();

            //Assert
            Assert.NotNull(currentKey);
        }
Exemple #2
0
        public void SetAPIKeyShouldChangeKey(string key)
        {
            //Arrange
            OpenWeaherAPI api        = new OpenWeaherAPI();
            string        currentKey = api.GetAPIKey();

            Assert.NotSame(currentKey, key);
            //Act
            api.SetAPIKey(key);
            //Assert
            currentKey = api.GetAPIKey();
            Assert.Equal(currentKey, key);
        }
Exemple #3
0
        private async Task <List <Forecast> > LoadDataFromWebservice(List <City> observedCities)
        {
            List <Forecast> forecastDTOs = new List <Forecast>();
            Forecast        forecastDTO;
            OpenWeaherAPI   openWeaher = new OpenWeaherAPI();

            foreach (var city in observedCities)
            {
                try
                {
                    forecastDTO = await openWeaher.GetForecast(city.ServiceId);
                }
                catch (Exception)
                {
                    logger.WriteMessage("Failed to get a forecast from webservice.");
                    continue;
                }
                forecastDTOs.Add(forecastDTO);
            }
            return(forecastDTOs);
        }