Esempio n. 1
0
		public void TestService ()
		{
			// Apache SOAP / RPC
		
			TemperatureService ts = new TemperatureService ();
			float temp = ts.getTemp ("95110");
			Assert.IsTrue (temp < 140 && temp > -60);
			
			temp = ts.getTemp ("hola");
			Assert.IsTrue (temp == -999);
		}
        public void TestService()
        {
            // Apache SOAP / RPC

            TemperatureService ts = new TemperatureService();
            float temp            = ts.getTemp("95110");

            Assert.IsTrue(temp <140 && temp> -60);

            temp = ts.getTemp("hola");
            Assert.IsTrue(temp == -999);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the temperature and updates the tray icon, the tray text, and displays when appropriate.
        /// </summary>
        private void GetTemp()
        {
            // Keep up with the last temperature.
            this._lastTemp = this._temp;

            try
            {
                // Try to use the webservice to get the temperature.
                this._temp = service.getTemp(this._zipCode.ToString());

                // Clear the error flag.
                this._wasError = false;
            }
            catch (WebException webException)
            {
                // If an exception is thrown then make the icon and text question marks.
                this.UpdateIcon("??");
                this.tray.Text = "??";

                // Then display a message and set the error flag if the option is enabled.
                if (this._showErrors == true)
                {
                    MessageBox.Show(this, webException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    this._wasError = true;
                }
            }
            catch (SocketException socketException)
            {
                // If an exception is thrown then make the icon and text question marks.
                this.UpdateIcon("??");
                this.tray.Text = "??";

                // Then display a message and set the error flag if the option is enabled.
                if (this._showErrors == true)
                {
                    MessageBox.Show(this, socketException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    this._wasError = true;
                }
            }
            catch (Exception exception)
            {
                // If an exception is thrown then make the icon and text question marks.
                this.UpdateIcon("??");
                this.tray.Text = "??";

                // Then display a message and set the error flag if the option is enabled.
                if (this._showErrors == true)
                {
                    MessageBox.Show(this, exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    this._wasError = true;
                }
            }

            // If the temperature is the same as the last time it checked, no need to update the icon.
            if (_temp != _lastTemp)
            {
                // Change the icon to the new temperature.
                this.UpdateIcon(_temp.ToString() + "°");

                // Change the tray text to the new temperature.
                this.tray.Text = _temp.ToString() + "°";
            }
        }