public static async Task Main()
        {
            ConsoleWriter.WriteGreeting();
            AWeatherAPI tomorrowWeatherAPI   = new TomorrowAPI();
            AWeatherAPI stormGlassWeatherAPI = new StormGlassAPI();

            do
            {
                await ShowWeatherInfo(tomorrowWeatherAPI);
                await ShowWeatherInfo(stormGlassWeatherAPI);
            } while (CheckKeybord());
        }
Пример #2
0
        public void InitializeWeatherAPITest()
        {
            AWeatherAPI tomorrowAPI = new TomorrowAPI();
            AWeatherAPI stormGlass  = new StormGlassAPI();
            HttpClient  client      = StormGlassAPI.Client;

            Assert.AreEqual(tomorrowAPI.URL, "https://api.tomorrow.io/v4/timelines?location=59.93863%2C%2030.31413&fields=temperature&fields=humidity&fields=windSpeed&fields=windDirection&fields=precipitationProbability&fields=cloudCover&units=metric&timesteps=current&timezone=Europe%2FMoscow&apikey=");
            Assert.AreEqual(tomorrowAPI.Flag, true);
            Assert.AreEqual(stormGlass.URL, "https://api.stormglass.io/v2/weather/point?lat=59.93863&lng=30.31413&params=airTemperature,cloudCover,humidity,precipitation,windDirection,windSpeed");
            Assert.AreEqual(stormGlass.Flag, true);

            Assert.AreEqual(TomorrowAPI.Client, client);
            Assert.AreEqual(StormGlassAPI.Client, client);
            Assert.AreEqual(AWeatherAPI.Client, client);
            Assert.AreEqual(IWeatherAPI.Client, null);
        }
Пример #3
0
        public async Task GetTomorrowWeatherModelTest()
        {
            IWeatherAPI  tomorrowAPI = new TomorrowAPI();
            WeatherModel model       = new WeatherModel()
            {
                Temperature = "6.19",
                CloudCover  = "36",
                Humidity    = "62",
                PrecipitationProbability = "0",
                WindDirection            = "62.69",
                WindSpeed = "3.13"
            };

            var weatherAPI = new Mock <IWeatherAPI>();

            weatherAPI
            .Setup(x => x.GetDataAsync())
            .ReturnsAsync("{\"data\":{\"timelines\":[{\"timestep\":\"current\",\"endTime\":\"2022 - 05 - 20T23: 02:00 + 03:00\",\"startTime\":\"2022 - 05 - 20T23: 02:00 + 03:00\",\"intervals\":[{\"startTime\":\"2022 - 05 - 20T23: 02:00 + 03:00\",\"values\":{\"cloudCover\":36,\"humidity\":62,\"precipitationProbability\":0,\"temperature\":6.19,\"windDirection\":62.69,\"windSpeed\":3.13}}]}]}}");

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

            Assert.AreEqual(model, gotModel);
        }