コード例 #1
0
        public void GivenMockResponse_OpenWeatherMap_TransformResponse_ShouldReturnValidData()
        {
            using (StreamReader r = new StreamReader("openWeatherMapResponse.json"))
            {
                string mockResponse = r.ReadToEnd();

                IOptions <OpenWeatherMapConfig> config = Options.Create(new OpenWeatherMapConfig
                {
                    Units = UnitsEnum.Metric
                });
                OpenWeatherMapService weatherMapService = new OpenWeatherMapService(config);
                var(weatherOutput, error) = weatherMapService.TransformResponse(mockResponse);

                Assert.Empty(error);
                Assert.Equal((decimal)14.79, weatherOutput.temperature_degrees);
                Assert.Equal((decimal)(9.8 * 3.6), weatherOutput.wind_speed);
            }
        }