public void GetHighTempTest() { WeatherSqlDAL dal = new WeatherSqlDAL(connectionString); List <Weather> model = dal.GetWeather("ENP"); Assert.AreEqual(82, model[0].HighTemp); }
public ActionResult Detail(string id) { if (id == null) { id = "CVNP"; } ParkSqlDAL ParkSql = new ParkSqlDAL(connectionString); var tempValue = Session["tempValue"]; if (tempValue == null) { tempValue = 0; } WeatherSqlDAL sqlweather = new WeatherSqlDAL(connectionString); ParkModel park = ParkSql.SelectedParkDecriptiveDetails(id); park.WeatherList = sqlweather.SpecificParkWeather(id); Session["tempValue"] = tempValue; park.TempValueProperty = (int)tempValue; ViewBag.WeatherData = park.WeatherList; return(View("Detail", park)); }
public ActionResult Weather(string id) { IParkDAL DAL = new ParkSqlDAL(); List <Park> ParkList = DAL.getAllParksData(); List <Weather> weather = new List <Weather>(); foreach (Park p in ParkList) { if (id == p.ParkCode) { IWeatherDAL thisDAL = new WeatherSqlDAL(); weather = thisDAL.getWeatherByParkCode(p.ParkCode); } } bool isFaranheight; Session["Tempature"] = Request.Params["Tempature"]; if (Session["Tempature"] != null) { if (Session["Tempature"].ToString() == "F") { isFaranheight = true; } else { isFaranheight = false; } } else { isFaranheight = true; } // update to Faranheight or Celcius for (int i = 0; i < weather.Count; i++) { if (isFaranheight) { if (weather[i].Tempature == "F") { continue; } else { weather[i].Tempature = "F"; weather[i].High = ChangeFaranheightToCelcius(weather[i].High, "F"); weather[i].Low = ChangeFaranheightToCelcius(weather[i].Low, "F"); } } else { weather[i].Tempature = "C"; weather[i].High = ChangeFaranheightToCelcius(weather[i].High, "C"); weather[i].Low = ChangeFaranheightToCelcius(weather[i].Low, "C"); } } return(View("Weather", weather)); }
// GET: Weather public ActionResult Weather(string id) { IParkSqlDAL dal = new ParkSqlDAL(connectionString); List <Park> ParkList = dal.GetAllParkData(); List <Weather> weather = new List <Weather>(); foreach (Park park in ParkList) { if (id == park.ParkCode) { IWeatherSqDAL thisDal = new WeatherSqlDAL(connectionString); weather = thisDal.GetWeatherByParkCode(park.ParkCode); } } bool isFahrenheit = true; Session["Temperature"] = Request.Params["Temperature"]; if (Session["Temperature"] != null) { if (Session["Temperature"].ToString() == "F") { isFahrenheit = true; } else { isFahrenheit = false; } } //Fahrenheit to Celsius for (int i = 0; i < weather.Count; i++) { if (isFahrenheit) { if (weather[i].Temperature == "F") { continue; } else { weather[i].Temperature = "F"; weather[i].High = ConvertFahrenheitToCelsius(weather[i].High, "F"); weather[i].Low = ConvertFahrenheitToCelsius(weather[i].Low, "F"); } } else { weather[i].Temperature = "C"; weather[i].High = ConvertFahrenheitToCelsius(weather[i].High, "C"); weather[i].Low = ConvertFahrenheitToCelsius(weather[i].Low, "C"); } } return(View("Weather", weather)); }
public void GetWeatherByParkCodeTest() { WeatherSqlDAL surveySqlDAL = new WeatherSqlDAL(connectionString); List <Weather> surveys = surveySqlDAL.GetWeatherByParkCode("AAA"); Assert.IsNotNull(surveys); Assert.AreEqual(1, surveys[0].FiveDayForecastValue); Assert.AreEqual(2, surveys[1].FiveDayForecastValue); }
public void GetWeatherTest_ParkCode() { List <Weather> result = new List <Weather>(); WeatherSqlDAL weather = new WeatherSqlDAL(connectionString); result = weather.GetWeather("ENP"); Assert.AreEqual("ENP", result[1].ParkCode); }
public void GetWeatherForParkTest() { WeatherSqlDAL weatherSqlDAL = new WeatherSqlDAL(connectionString); List <Weather> weatherForPark = weatherSqlDAL.GetWeatherForPark("ABC"); Assert.AreEqual(5, weatherForPark.Count); Assert.AreEqual("rain", weatherForPark[0].Forecast); Assert.AreEqual(5, weatherForPark[4].FiveDayForecast); Assert.AreEqual(70, weatherForPark[3].LowTemp); }
public void ParkSqlDAL_GetWeatherByCode_Test() { //Arrange IWeatherSqDAL weatherDAL = new WeatherSqlDAL(connectionString); //Act List <Weather> weather = weatherDAL.GetWeatherByParkCode("CVNP"); //Assert Assert.IsNotNull(weatherDAL); Assert.IsNotNull(weather); }
public void ParkSqlDAL_GetAllWeather_Test() { //Arrange IWeatherSqDAL weatherDAL = new WeatherSqlDAL(connectionString); //Act List <Weather> allWeather = weatherDAL.GetAllWeather(); //Assert Assert.IsNotNull(weatherDAL); Assert.IsNotNull(allWeather); }
public void Get5DayWeatherTest() { WeatherSqlDAL sqlDAL = new WeatherSqlDAL(connectionString); List <Weather> ListOfParkWeather = sqlDAL.Get5DayWeather("NNN"); Assert.IsNotNull(ListOfParkWeather); Assert.AreEqual(numWeather, ListOfParkWeather.Count); Assert.AreEqual("NNN", ListOfParkWeather[0].ParkCode); Assert.AreEqual(1, ListOfParkWeather[0].FiveDayForcastValue); Assert.AreEqual(5, ListOfParkWeather[4].FiveDayForcastValue); }
public void GetAllParksTest() //IList<Park> GetAllParks() { //Arrange IWeatherDAL weatherSqlDAL = new WeatherSqlDAL(connectionString); //ACT IList <Weather> yosemiteWeather = weatherSqlDAL.GetWeatherByPark("YNP2"); //Assert Assert.IsNotNull(yosemiteWeather, "Parks list is empty!"); Assert.AreEqual(weatherCount, yosemiteWeather.Count, $"Expected a count of {weatherCount} for yosemite's weather."); }
public void GetForecastsTest() { //Arrange WeatherSqlDAL weatherSqlDal = new WeatherSqlDAL(connectionString, true); //Act List <Weather> forecasts = weatherSqlDal.GetForecast("gnp"); //Assert Assert.IsNotNull(forecasts); Assert.AreEqual(numberOfForecasts, forecasts.Count); }
public void HomeController_IndexAction_ReturnIndexView() { ParkSqlDAL parkDAL = new ParkSqlDAL(ConfigurationManager.ConnectionStrings["ParkWeather"].ConnectionString); WeatherSqlDAL weatherDAL = new WeatherSqlDAL(ConfigurationManager.ConnectionStrings["ParkWeather"].ConnectionString); //Arrange HomeController controller = new HomeController(parkDAL, weatherDAL); //Act ViewResult result = controller.Index() as ViewResult; //Assert Assert.AreEqual("Index", result.ViewName); }
public void GetWeatherTest() { WeatherSqlDAL weatherSqlDAL = new WeatherSqlDAL(connectionString); List <Weather> weathers = weatherSqlDAL.GetWeather(); int result = 0; foreach (Weather weather in weathers) { if (weather.ParkCode == "ABC") { result++; } } Assert.AreEqual(5, result); }
public HomeController() { this.pdal = new ParkSqlDAL(@"Data Source=.\sqlexpress;Initial Catalog=NPGeek;Integrated Security=True"); this.wdal = new WeatherSqlDAL(@"Data Source=.\sqlexpress;Initial Catalog=NPGeek;Integrated Security=True"); }