public void WeatherData_Construct_WithDB() { // Set up params for constructor int rowID = 1; int stationID = 2; int month = 1; double tempMin = 2; double tempMax = 3; double humidity = 4; double wind = 5; double sun = 6; double radiation = 7; double eto = 8; double rain = 9; double effRain = 10; //Construct WeatherData wd = new WeatherData(rowID, stationID, month, tempMax, tempMin, humidity, wind, sun, radiation, eto, rain, effRain); // Assert Assert.AreEqual(rowID, wd.rowid); Assert.AreEqual(stationID, wd.stationRowID); Assert.AreEqual(month, wd.month); Assert.AreEqual(tempMin, wd.tempMin); Assert.AreEqual(tempMax, wd.tempMax); Assert.AreEqual(humidity, wd.humidity); Assert.AreEqual(wind, wd.wind); Assert.AreEqual(sun, wd.sun); Assert.AreEqual(radiation, wd.radiation); Assert.AreEqual(eto, wd.eto); Assert.AreEqual(rain, wd.rain); Assert.AreEqual(effRain, wd.effRain); }
public void MetStation_AvgTemp_MoreThan12Months() { MetStation m = new MetStation(); WeatherData wd = new WeatherData(); // Add less than 12 weather data points for (int i = 1; i <= 13; i++) { m.weatherData.Add(wd); } try { double avgMin = m.AvgTemp(m.weatherData); Assert.Fail("Excepted Exception"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void MetStation_AvgTemp_12Months() { MetStation m = new MetStation("a", "b", "c", "d", 1, 2, 3); WeatherData wd = new WeatherData(); wd.tempAvg = 2; // Add less than 12 weather data points for (int i = 1; i <= 12; i++) { m.weatherData.Add(wd); } try { double avgMin = m.AvgTemp(m.weatherData); } catch (Exception e) { Console.WriteLine(e.Message); Assert.Fail("No Exception Expected"); } }
public void MetStation_AvgTemp_AvgTestSimple() { MetStation m = new MetStation(); WeatherData wd = new WeatherData(); wd.tempAvg = 2; // Add less than 12 weather data points for (int i = 1; i <= 12; i++) { m.weatherData.Add(wd); } try { double avgMin = m.AvgTemp(m.weatherData); Assert.AreEqual(2, avgMin); } catch (Exception e) { Console.WriteLine(e.Message); Assert.Fail("No Exception Expected"); } }
public void WeatherData_AvgTemp_Simple() { WeatherData wd = new WeatherData(); double result = wd.CalculateAvgTemp(1,1); Assert.AreEqual(1, result); }
public void WeatherData_AvgTemp_Complex() { WeatherData wd = new WeatherData(); double result = wd.CalculateAvgTemp(23,15); Assert.AreEqual(19, result); }
public ArrayList GetWeatherData(int rowid) { string query = "SELECT * FROM weather_data WHERE station_id=" + rowid + " ORDER BY month ASC"; try { this.OpenConnection(); SqliteDataReader reader = this.ExecuteQuery(query); WeatherData data = null; ArrayList list = new ArrayList(); while (reader.Read()) { data = new WeatherData(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetDouble(3), reader.GetDouble(4), reader.GetDouble(5), reader.GetDouble(6), reader.GetDouble(7), reader.GetDouble(8), reader.GetDouble(9), reader.GetDouble(10), reader.GetDouble(11)); list.Add(data); } if (data == null) { throw new Exception("No WeatherData matches those parameters."); } // Close Reader and Connection reader.Close(); reader = null; this.CloseConnection(); return list; } catch (Exception e) { // Cannot connect to DB throw e; } }