예제 #1
0
        public void TestAPIReturnTemp()
        {
            EndProject.WeatherAPI api = new WeatherAPI("Perth, AU");
            string apiData            = api.GetTemp().ToString();

            Assert.AreEqual(true, checkApiData(apiData));
        }
예제 #2
0
        public ActionResult test()
        {
            WeatherAPI wapi  = new WeatherAPI("manisa");
            var        _Temp = wapi.GetMeteoData();

            return(View());
        }
        public ActionResult Create()
        {
            string tomorrowWeather = WeatherAPI.CallAPITomorrowWeather();

            ViewBag.weather = tomorrowWeather;
            return(View());
        }
예제 #4
0
        public async void Call_API_And_Return_Weather()
        {
            var api     = new WeatherAPI();
            var weather = await api.GetWeather();

            Assert.NotNull(weather);
        }
예제 #5
0
        public void SetupParameters_emptyList()
        {
            var sut = new WeatherAPI();

            Assert.That(sut.ZipList.Count, Is.EqualTo(0));
            Assert.That(sut.Timers.Count, Is.EqualTo(0));
        }
예제 #6
0
 void Start()
 {
     weather   = WeatherAPI.FindObjectOfType <WeatherAPI>();
     windspeed = weather.wind;
     Force.x   = windspeed;
     Debug.Log(windspeed);
 }
예제 #7
0
파일: SkyAPI.cs 프로젝트: hafewa/Weather
    // Use this for initialization
    void Start()
    {
        //get WeatherAPI
        weather = WeatherAPI.FindObjectOfType <WeatherAPI>();

        Debug.Log("found sky API");
    }
예제 #8
0
        void SetupHandler()
        {
            BtnReconnect.Click += (a, b) =>
            {
                SetupMqtt(true);
                //await TryReconnectAsync(CancellationToken.None);
            };
            BtnRestart.Click += (a, b) =>
            {
                Windows.System.ShutdownManager.BeginShutdown(Windows.System.ShutdownKind.Restart, TimeSpan.FromSeconds(1));
            };

            BtnLihat.Click += async(a, b) =>
            {
                if (string.IsNullOrEmpty(TxtKota.Text))
                {
                    // Create the message dialog and set its content
                    var messageDialog = new MessageDialog("Isi nama kotanya, goblok");

                    // Show the message dialog
                    await messageDialog.ShowAsync();

                    return;
                }
                var temps = await WeatherAPI.GetWeatherInfo(TxtKota.Text);

                var data = from x in temps.list
                           select new { day = Convert.ToDateTime(x.dt_txt), x.main.temp, x.main.temp_min, x.main.temp_max, x.main.humidity, x.main.pressure };
                ListWeather.ItemsSource = data.ToList();
            };
            BtnPlay.Click += (a, b) => { PlaySound("monster.mp3"); };
            BtnD1.Click   += ToggleLedClicked;
            BtnD2.Click   += ToggleLedClicked;
        }
예제 #9
0
        public void CheckWeather()
        {
            WeatherAPI DataAPI = new WeatherAPI(City);

            temp       = DataAPI.GetTemp();
            Precipmode = DataAPI.GetPrecipMode();
        }
예제 #10
0
        public Weather GetWeather()
        {
            Weather weather = new WeatherAPI(txtcity.Text).FetchData();

            Console.WriteLine();
            Console.WriteLine(weather.weather.First().description);
            return(weather);
        }
예제 #11
0
 // Use this for initialization
 // Use this for initialization
 void Start()
 {
     knowsWeather = false;
     //find the text of this component
     windText = GameObject.Find("WindText").GetComponent <Text>();
     //gets the weather from the API
     weather = WeatherAPI.FindObjectOfType <WeatherAPI>();
 }
예제 #12
0
 public void Start()
 {
     _worker      = new Thread(DoWorkNew);
     endFlag      = true;
     _worker.Name = "CE Worker";
     weatherAPI   = new WeatherAPI();
     _worker.Start();
 }
예제 #13
0
        private void getWeather(LanguageCode Lang, string City)
        {
            try
            {
                //Get the data
                wD = WeatherAPI.GetWeather(Lang, City, celsius);

                //Set image locations
                string baseURL      = "http://www.google.com";
                string iconToday    = baseURL + wD.iconTODAY;
                string icon         = baseURL + wD.icon;
                string iconTOMORROW = baseURL + wD.iconTOMORROW;
                string iconDAY2     = baseURL + wD.iconDAY2;
                string iconDAY3     = baseURL + wD.iconDAY3;

                //Set images
                icnCurrent.ImageLocation  = icon;
                icnDay2.ImageLocation     = iconDAY2;
                icnDay3.ImageLocation     = iconDAY3;
                icnToday.ImageLocation    = iconToday;
                icnTomorrow.ImageLocation = iconTOMORROW;

                //Current Conditions
                lblCity.Text        = wD.city;
                lblCurrentCond.Text = wD.condition;
                lblCurrentF.Text    = temp + ": " + wD.temp_f.ToString() + degree;
                lblWind.Text        = wD.wind_condition;

                //Day 2's Conditions
                lblDay2.Text     = wD.day_of_weekDAY2;
                lblDay2Cond.Text = wD.conditionDAY2;
                lblDay2High.Text = high + ":  " + wD.highDAY2.ToString() + degree;
                lblDay2Low.Text  = low + ":  " + wD.lowDAY2.ToString() + degree;

                //Day 3's Conditions
                lblDay3.Text     = wD.day_of_weekDAY3;
                lblDay3Cond.Text = wD.conditionDAY3;
                lblDay3High.Text = high + ":  " + wD.highDAY3.ToString() + degree;
                lblDay3Low.Text  = low + ":  " + wD.lowDAY3.ToString() + degree;

                //Today's Conditions
                lblToday.Text     = wD.day_of_weekTODAY;
                lblTodayCond.Text = wD.conditionTODAY;
                lblTodayHigh.Text = high + ":  " + wD.highTODAY.ToString() + degree;
                lblTodayLow.Text  = low + ":  " + wD.lowTODAY.ToString() + degree;

                //Tomorrow's Conditions
                lblTomorrow.Text     = wD.day_of_weekTOMORROW;
                lblTomorrowCond.Text = wD.conditionTOMORROW;
                lblTomorrowHigh.Text = high + ":  " + wD.highTOMORROW.ToString() + degree;
                lblTomorrowLow.Text  = low + ":  " + wD.lowTOMORROW.ToString() + degree;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        public JsonResult GetWeather(string destination)
        {
            Geolocation geolocation  = MapFunctions.Locate(destination);
            WeatherData todayWeather = new WeatherData();
            WeatherAPI  weather      = new WeatherAPI(geolocation.Latitude, geolocation.Longitude);

            todayWeather = weather.GetWeather(destination);
            return(Json(todayWeather, JsonRequestBehavior.AllowGet));
        }
예제 #15
0
 public HourlyDisplayData(WeatherAPI wAPI, IpData locationInfo)
 {
     // Iterira kroz data niz hourly dela JSON response-a i
     // prikuplja informacije za <displayHourCount> sat(a).
     foreach (CurrentWeatherData iter in wAPI.hourly.data)
     {
         string hourLabel = GenerateHourLabel(iter.time);
         displayHours.Add(new HourData(hourLabel, iter.icon, Math.Round(iter.temperature, 0) + "°C", "" + (iter.precipProbability * 100) + " %"));
     }
 }
예제 #16
0
 public WeeklyDisplayData(WeatherAPI wAPI, IpData locationInfo)
 {
     // Iterira kroz data niz daily dela JSON response-a i
     // prikuplja informacije za <displayDayCount> dan(a).
     foreach (DailyWeatherData iter in wAPI.daily.data)
     {
         string dayLabel = GenerateDayLabel(iter.time);
         displayDays.Add(new DayData(dayLabel, iter.icon, "Max: " + Math.Round(iter.temperatureMax, 0) + "°C \nMin: " + Math.Round(iter.temperatureMin, 0) + "°C", "" + (iter.precipProbability * 100) + "%"));
     }
 }
예제 #17
0
        //GetWeather method for the veiw that reutrns the users zipcode
        public JsonResult GetWeather()
        {
            var        userId  = User.Identity.GetUserId();
            USER_EXT   ext     = db.User_ext.SingleOrDefault(u => u.USER_ID == userId);
            WeatherAPI weather = new WeatherAPI();

            //return json of getweatherforcast method
            //AllowGet
            return(Json(weather.getWeatherForcast(ext.ZIPCODE), JsonRequestBehavior.AllowGet));
        }
예제 #18
0
 public MainWindow(object w, string user)
 {
     InitializeComponent();
     TestConnection();
     callWindow = (Window)w;
     User       = user;
     cases      = repository.GetAllCases();
     InvokeUserControls();
     weatherAPI = new WeatherAPI(labelWeather);
     weatherAPI.GetCityNameAsync();
 }
예제 #19
0
        public void ZipList_AddNewValues()
        {
            var sut = new WeatherAPI();

            sut.ZipList.Add(new ZipInformation {
                ZipCode = "30004", Interval = 6000
            });

            Assert.That(sut.ZipList, Has.Exactly(1).Matches <ZipInformation>(item => item.ZipCode == "30004" && item.Interval == 6000));
            Assert.That(sut.ZipList, Has.Exactly(0).Matches <ZipInformation>(item => item.ZipCode == "30188" && item.Interval == 6000));
        }
 public ValuesController(
     IWeatherService weatherService, IMapper mapper,
     IUserService userService, IConfiguration configuration
     )
 {
     _weatherService = weatherService;
     _userService    = userService;
     _mapper         = mapper;
     Configuration   = configuration;
     weatherAPI      = new WeatherAPI();
 }
예제 #21
0
 public void forecastHumidityTests()
 {
     WeatherAPI api = new WeatherAPI();
     api.isTest = true;
     var forecastWeather = api.GetforecastWeather("2163355").Result;
     Assert.AreEqual(forecastWeather[0][1].MainData.Humidity, 72);
     Assert.AreEqual(forecastWeather[1][3].MainData.Humidity, 68);
     Assert.AreEqual(forecastWeather[1][6].MainData.Humidity, 71);
     Assert.AreEqual(forecastWeather[3][5].MainData.Humidity, 69);
     Assert.AreEqual(forecastWeather[4][5].MainData.Humidity, 72);
 }
예제 #22
0
        public ForecastController()
        {
            // Dohvatanje forecastApp instance.
            forecastAppInstance = ForecastApp.GetInstance();

            // Weather info.
            weatherAPI = forecastAppInstance.WeatherDataFromJSON();

            // City info.
            locationInfo = forecastAppInstance.IpAPIData;
        }
예제 #23
0
 public void forecastCallCounts()
 {
     WeatherAPI api = new WeatherAPI();
     api.isTest = true;
     var forecastWeather = api.GetforecastWeather("2163355").Result;
     Assert.AreEqual(forecastWeather[0].Count, 7);
     Assert.AreEqual(forecastWeather[1].Count, 8);
     Assert.AreEqual(forecastWeather[2].Count, 8);
     Assert.AreEqual(forecastWeather[3].Count, 8);
     Assert.AreEqual(forecastWeather[4].Count, 9);
 }
        public ActionResult Create(EoDLunchOrderModels Model)
        {
            db.Lunch.Add(Model);
            DateTime Clock = DateTime.Now;

            Model.DayOfWeek        = (int)Clock.DayOfWeek;
            Model.TomorrowsWeather = WeatherAPI.CallAPITomorrowWeather();
            Model.Date             = DateTime.Now.ToString("dd/MM/yyyy");
            db.SaveChanges();
            return(RedirectToAction("Bingus", "EoDLunchOrderController"));
        }
예제 #25
0
 public void forecastWeatherTypeTests()
 {
     WeatherAPI api = new WeatherAPI();
     api.isTest = true;
     var forecastWeather = api.GetforecastWeather("2163355").Result;
     Assert.AreEqual(forecastWeather[0][1].WeatherInfo[0].WeatherType, "Rain");
     Assert.AreEqual(forecastWeather[0][4].WeatherInfo[0].WeatherType, "Rain");
     Assert.AreEqual(forecastWeather[2][2].WeatherInfo[0].WeatherType, "Rain");
     Assert.AreEqual(forecastWeather[2][7].WeatherInfo[0].WeatherType, "Rain");
     Assert.AreEqual(forecastWeather[4][2].WeatherInfo[0].WeatherType, "Clear");
     Assert.AreEqual(forecastWeather[4][8].WeatherInfo[0].WeatherType, "Clouds");
 }
예제 #26
0
 public void forecastRainfallTests()
 {
     WeatherAPI api = new WeatherAPI();
     api.isTest = true;
     var forecastWeather = api.GetforecastWeather("2163355").Result;
     Assert.AreEqual(forecastWeather[0][1].RainFall.RainVolumeOverPast3Hours, 1.13f);
     Assert.AreEqual(forecastWeather[0][4].RainFall.RainVolumeOverPast3Hours, 0.13f);
     Assert.AreEqual(forecastWeather[2][2].RainFall.RainVolumeOverPast3Hours, 0.19f);
     Assert.AreEqual(forecastWeather[2][7].RainFall.RainVolumeOverPast3Hours, 0.5f);
     Assert.AreEqual(forecastWeather[4][2].RainFall, null);
     Assert.AreEqual(forecastWeather[4][8].RainFall, null);
 }
예제 #27
0
        public IActionResult TestData()
        {
            WeatherAPI api = new WeatherAPI();

            Task <WeatherResponse> apitask = Task.Factory.StartNew(() => api.GetWeatherData());

            apitask.Wait();

            WeatherResponse weatherdata = apitask.Result;

            return(RedirectToAction("Widget", weatherdata));
        }
예제 #28
0
 // Start is called before the first frame update
 void Start()
 {
     api         = api.gameObject.GetComponent <WeatherAPI>();
     audioSource = this.GetComponentInParent <AudioSource>();
     for (int i = 0; i < weatherObjects.Length; i++)
     {
         weatherObjects[i].SetActive(false);
     }
     for (int i = 0; i < particles.Length; i++)
     {
         particles[i].SetActive(false);
     }
 }
예제 #29
0
 public void forecastTempTests()
 {
     WeatherAPI api = new WeatherAPI();
     api.isTest = true;
     var forecastWeather = api.GetforecastWeather("2163355").Result;
     Assert.AreEqual(forecastWeather[0][0].MainData.Temperature, 9);
     Assert.AreEqual(forecastWeather[0][0].MainData.Temperature, 9);
     Assert.AreEqual(forecastWeather[2][6].MainData.Temperature, 11);
     Assert.AreEqual(forecastWeather[2][6].MainData.Temperature, 11);
     Assert.AreEqual(forecastWeather[1][3].MainData.Temperature, 10);
     Assert.AreEqual(forecastWeather[3][7].MainData.Temperature, 12);
     Assert.AreEqual(forecastWeather[4][3].MainData.Temperature, 12);
 }
예제 #30
0
        public async Task GetWeatherFor(string city)
        {
            var wapi    = new WeatherAPI();
            var results = await wapi.Get(city);

            var sb = new StringBuilder(4);

            foreach (var item in results.list.Where(i => i.Date > DateTime.Now).Take(3))
            {
                sb.AppendLine(item.ToString());
            }
            Clients.Caller.addBotWeatherToPage(sb.ToString());
        }