Example #1
0
        public async Task GetStormGlassWeatherModelTest()
        {
            IWeatherAPI  stormGlassAPI = new StormGlassAPI();
            WeatherModel model         = new WeatherModel()
            {
                Temperature = "11.73",
                CloudCover  = "0",
                Humidity    = "33.98",
                PrecipitationProbability = "0",
                WindDirection            = "35.22",
                WindSpeed = "3.71"
            };

            var weatherAPI = new Mock <IWeatherAPI>();

            weatherAPI
            .Setup(x => x.GetDataAsync())
            .ReturnsAsync("{\"hours\":[{\"airTemperature\":{\"sg\":11.73},\"cloudCover\":{\"sg\":0.0},\"humidity\":{\"sg\":33.98},\"precipitation\":{\"sg\":0.0},\"time\":\"2022 - 05 - 22T16: 00:00 + 00:00\",\"windDirection\":{\"sg\":35.22},\"windSpeed\":{\"sg\":3.71}}],\"meta\":{\"cost\":1,\"dailyQuota\":10,\"end\":\"2022 - 05 - 22 16:11\",\"lat\":59.93863,\"lng\":30.31413,\"params\":[\"airTemperature\",\"cloudCover\",\"humidity\",\"precipitation\",\"windDirection\",\"windSpeed\"],\"requestCount\":3,\"source\":[\"sg\"],\"start\":\"2022 - 05 - 22 16:00\"}}");

            WeatherModel gotModel = stormGlassAPI.GetWeatherModelAsync(await weatherAPI.Object.GetDataAsync());

            Assert.AreEqual(model, gotModel);
        }