Exemple #1
0
        public void GetForecast_ShouldCallRequiredMethods()
        {
            //ARRANGE
            var provider = new WeatherUndergroundProvider(requestHandler.Object, mapper.Object, settingsManager.Object);

            settingsManager.Setup(x => x.Get(It.IsAny <string>())).Returns(string.Empty);

            //ACT
            var model = provider.GetForecast(1, 2);

            //ASSERT
            settingsManager.Verify(x => x.Get(It.IsAny <string>()), Times.Exactly(2));
            requestHandler.Verify(x => x.GetDeserializedObjectFromRequest <WeatherUndergroundModel>(It.IsAny <string>()), Times.Once);
            mapper.Verify(x => x.Map(It.IsAny <WeatherUndergroundModel>()), Times.Once);
        }
        // Static Methods
        public static WeatherProviderImpl GetProvider(string API)
        {
            WeatherProviderImpl providerImpl = null;

            switch (API)
            {
            case WeatherAPI.Yahoo:
                providerImpl = new YahooWeatherProvider();
                break;

            case WeatherAPI.WeatherUnderground:
                providerImpl = new WeatherUndergroundProvider();
                break;

            case WeatherAPI.Here:
                providerImpl = new HEREWeatherProvider();
                break;

            case WeatherAPI.OpenWeatherMap:
                providerImpl = new OpenWeatherMapProvider();
                break;

            case WeatherAPI.MetNo:
                providerImpl = new MetnoWeatherProvider();
                break;

            default:
                break;
            }

            if (providerImpl == null)
            {
                throw new ArgumentNullException(nameof(API), "Invalid API name! This API is not supported");
            }

            return(providerImpl);
        }