/// <summary>
        /// API Wrapper generator
        /// </summary>
        /// <param name="source">Selected API Enum Value</param>
        /// <returns></returns>
        public IWeatherApi Make(int source)
        {
            // We get the current source's options
            var option = _optionsAccessor.Value.WeaherApiOption[source];
            if (!option.Name.Equals(((Source) source).ToString()))
                throw new Exception("Badly Configured Parameters");

            // Based on the source we initialize the desired wrapper and set it's KEY
            IWeatherApi implementation;
            switch ((Source) source)
            {
                case Source.ForecastIo:
                    implementation = new ForecastIo.ForecastIo(_forecastClient);
                    break;
                case Source.WeatherUnderground:
                    implementation = new Wunderground.Wunderground(_wunderClient);
                    break;
                case Source.WorldWeatherOnline:
                    implementation = new WorldWeatherOnline.WorldWeatherOnline(_wwoClient);
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(source), source, null);
            }
            implementation.ApiKey = option.Key;

            return implementation;
        }
Example #2
0
        private async void WhenForeCastIoMethodIsCalledRestClientGetLocalWeatherShouldBeCalled()
        {
            //Arrange
            var restClientMock = new Mock<IRestClient<EndPointResponse>>();
            var forecastIo = new ForecastIo(restClientMock.Object) {ApiKey = "0"};

            // Act
            await forecastIo.GetLocalWeather(0, 0);

            // Verify
            restClientMock.Verify(t => t.CallListEndPoint(It.IsAny<string>()));
        }