Ejemplo n.º 1
0
        public ActionResult FavoriteParks()
        {
            SurveySqlDAL       sql      = new SurveySqlDAL(connectionString);
            List <SurveyModel> thisList = sql.BestParks();

            return(View("FavoriteParks", thisList));
        }
Ejemplo n.º 2
0
        public ActionResult Survey(SurveyModel thisSurvey)
        {
            SurveySqlDAL sql = new SurveySqlDAL(connectionString);

            sql.SurveyPost(thisSurvey);
            return(RedirectToAction("FavoriteParks"));
        }
        public ActionResult SurveyResults()
        {
            SurveySqlDAL  surveySD   = new SurveySqlDAL(connectionString);
            List <Survey> allsurveys = surveySD.GetAllSurveys();

            return(View("SurveyResults", allsurveys));
        }
        // GET: Survey
        public ActionResult Index()
        {
            SurveySqlDAL  surveyDAL  = new SurveySqlDAL(connectionString);
            List <Survey> surveyList = surveyDAL.GetSurveys();

            return(View("Index", surveyList));
        }
        //GET: SurveyResults
        public ActionResult SurveyResults()
        {
            SurveySqlDAL         dal           = new SurveySqlDAL(connectionString);
            List <SurveyResults> surveyResults = dal.GetHighestVoteTotal();

            return(View("SurveyResults", surveyResults));
        }
Ejemplo n.º 6
0
        public void SaveNewSurveyTest() //void SaveNewSurvey(Survey survey)
        {
            //Arrange
            ISurveyDAL surveySqlDAL          = new SurveySqlDAL(connectionString);
            Dictionary <string, int> surveys = surveySqlDAL.GetFavoriteParkBySurveyCount();
            Survey survey = new Survey()
            {
                ParkCode      = "YNP2",
                Email         = "*****@*****.**",
                State         = "Ohio",
                ActivityLevel = "Inactive"
            };
            int before;

            if (surveys.ContainsKey("YNP2"))
            {
                before = surveys["YNP2"];
            }
            else
            {
                before = 0;
            }

            //ACT
            surveySqlDAL.SaveNewSurvey(survey);

            //check that the added survey increased the # of votes for yosemite by 1.
            Dictionary <string, int> surveysNew = surveySqlDAL.GetFavoriteParkBySurveyCount();
            int after = surveysNew["YNP2"];

            //Assert
            Assert.IsNotNull(surveysNew, "Yosemite should have at least 1 vote(survey).");
            Assert.AreEqual((before + 1), after, $"Yosemite should have had {before} surveys before the add and {after} surveys after the add.");
        }
Ejemplo n.º 7
0
        public void SQL_InsertSurvey_Tests()
        {
            SurveySqlDAL surveyDal = new SurveySqlDAL(connectionString);

            Assert.IsNotNull(surveyDal);
            Assert.AreEqual(1, rowsAffected);
        }
Ejemplo n.º 8
0
        public void GetAllSurveysTest()
        {
            SurveySqlDAL  surveyDAL  = new SurveySqlDAL(connectionString);
            List <Survey> surveyList = surveyDAL.GetAllSurveys();

            Assert.IsNotNull(surveyList);
            Assert.AreEqual(surveys, surveyList.Count);
        }
        public void GetParkSurveyResult()
        {
            SurveySqlDAL surveySqlDAL = new SurveySqlDAL(connectionString);

            List <ViewParksSurveyViewModel> surveys = surveySqlDAL.GetParkSurveyResult();

            Assert.IsNotNull(surveys);
        }
Ejemplo n.º 10
0
        public void GetAllPostsTest()
        {
            SurveySqlDAL dal = new SurveySqlDAL(connectionString);

            List <SurveyModel> result = dal.GetAllPosts();

            Assert.AreEqual(1, result.Count);
        }
Ejemplo n.º 11
0
        public void SaveNewSurveyTest()
        {
            SurveySqlDAL surveyDAL  = new SurveySqlDAL(connectionString);
            Survey       testSurvey = new Survey()
            {
                SurveyId = surveyId,
            };

            Assert.AreEqual(true, surveyDAL.SaveNewSurvey(testSurvey));
        }
 public ActionResult Survey(Survey survey)
 {
     if (ModelState.IsValid)
     {
         SurveySqlDAL dal = new SurveySqlDAL(connectionString);
         dal.SaveSurvey(survey);
         return(RedirectToAction("SurveyResults"));
     }
     return(View("Survey", survey));
 }
Ejemplo n.º 13
0
        public void GetResultsTest()
        {
            //Arrange
            SurveySqlDAL surveyDal = new SurveySqlDAL(connectionString);

            //Act
            List <Survey> results = surveyDal.GetResults();

            //Assert
            Assert.IsTrue(results.Count <= 10);
        }
Ejemplo n.º 14
0
        public void GetFavoriteParksTest()
        {
            SurveySqlDAL  sqlDAL = new SurveySqlDAL(connectionString);
            List <Survey> listOfFavoriteParks = sqlDAL.GetFavoriteParks();

            Assert.IsNotNull(listOfFavoriteParks);
            Assert.AreEqual(surveyCount + 3, listOfFavoriteParks.Count);
            Assert.AreEqual("GNC", listOfFavoriteParks[listOfFavoriteParks.FindIndex(list => list.ParkCode.Contains("GNC"))].ParkCode);
            Assert.AreEqual("NTP", listOfFavoriteParks[listOfFavoriteParks.FindIndex(list => list.ParkCode.Contains("NTP"))].ParkCode);
            Assert.AreEqual("NNN", listOfFavoriteParks[listOfFavoriteParks.FindIndex(list => list.ParkCode.Contains("NNN"))].ParkCode);
        }
Ejemplo n.º 15
0
        public void GetSurveysTest()
        {
            //Arrange
            SurveySqlDAL surveySqlDal = new SurveySqlDAL(connectionString);

            //Act
            List <Survey> surveys = surveySqlDal.GetSurveys();

            //Assert
            Assert.IsNotNull(surveys);
            Assert.AreEqual(numberOfParksWithSurvey, surveys.Count);
        }
        public void SubmitSurvey()
        {
            SurveySqlDAL surveySqlDAL = new SurveySqlDAL(connectionString);
            Survey       survey       = new Survey {
                ParkCode      = "AAA",
                EmailAddress  = "*****@*****.**",
                State         = "Ohio",
                ActivityLevel = "inactive"
            };

            Assert.IsTrue(surveySqlDAL.SubmitSurvey(survey));
        }
Ejemplo n.º 17
0
        public void SQL_ViewAllSurveys_Tests()
        {
            //Arrange
            SurveySqlDAL surveyDal = new SurveySqlDAL(connectionString);

            //Act
            List <Survey> allSurveys = surveyDal.ViewAllSurveys();

            //Assert
            Assert.IsNotNull(surveyDal);
            Assert.IsNotNull(allSurveys);
        }
Ejemplo n.º 18
0
        public void SurveySqlDAL_GetAllSurvey_Tests()
        {
            //Arrange
            SurveySqlDAL surveyDAL = new SurveySqlDAL();

            //Act
            List <Survey> allSurveies = surveyDAL.getAllSurvey();

            //Assert
            Assert.IsNotNull(surveyDAL);
            Assert.IsNotNull(allSurveies);
            Assert.AreEqual(6, allSurveies.Count);
        }
Ejemplo n.º 19
0
        public void NewSurveyTest()
        {
            SurveySqlDAL sqlDAL = new SurveySqlDAL(connectionString);
            Survey       survey = new Survey
            {
                ParkCode      = "GNC",
                Email         = "email",
                State         = "ohio",
                ActivityLevel = "high",
            };

            Assert.AreEqual(true, sqlDAL.NewSurvey(survey));
        }
Ejemplo n.º 20
0
        public void DisplaySurveys()
        {
            // Arrange
            ISurveyDAL sDAL = new SurveySqlDAL(connectionString);

            //Act
            IList <SurveyModel> survey = sDAL.DisplaySurveys();

            //Assert
            int surveyTotal = survey.Count;

            Assert.IsNotNull(survey);
            Assert.AreEqual(3, surveyTotal);
        }
Ejemplo n.º 21
0
        public void GetFavoriteParksTest()
        {
            SurveySqlDAL surveySqlDAL            = new SurveySqlDAL(connectionString);
            List <FavoriteParkViewModel> surveys = surveySqlDAL.GetFavoriteParks();

            Assert.IsNotNull(surveys);
            int totalVotes = 0;

            foreach (var model in surveys)
            {
                totalVotes += model.Votes;
            }
            Assert.AreEqual(_surveyCount, totalVotes);
        }
        public ActionResult SurveySubmit(SurveyForm surveyForm)
        {
            if (!ModelState.IsValid)
            {
                return(View("SurveySubmit", surveyForm));
            }

            SurveySqlDAL surveyDAL = new SurveySqlDAL(connectionString);

            surveyDAL.SubmitSurvey(surveyForm);

            TempData["StatusMessage"] = "Your Survey Has Been Saved";

            return(RedirectToAction("Index"));
        }
        public void SurveyController_FavoritesAction_ReturnFavoritesView()
        {
            //ParkSqlDAL parkDAL = new ParkSqlDAL(ConfigurationManager.ConnectionStrings["ParkWeather"].ConnectionString);
            //WeatherSqlDAL weatherDAL = new WeatherSqlDAL(ConfigurationManager.ConnectionStrings["ParkWeather"].ConnectionString);
            SurveySqlDAL surveyDAL = new SurveySqlDAL(ConfigurationManager.ConnectionStrings["ParkWeather"].ConnectionString);

            //Arrange
            SurveyController controller = new SurveyController(surveyDAL);

            //Act
            ViewResult result = controller.Favorites() as ViewResult;

            //Assert
            Assert.AreEqual("Favorites", result.ViewName);
        }
Ejemplo n.º 24
0
        public void SavePostTest()
        {
            SurveyModel model = new SurveyModel()
            {
                FavoritePark  = "Everglades National Park",
                Email         = "*****@*****.**",
                Residence     = "OH",
                ActivityLevel = "Low"
            };

            SurveySqlDAL dal = new SurveySqlDAL(connectionString);

            bool result = dal.SaveNewPost(model);

            Assert.AreEqual(true, result);
        }
Ejemplo n.º 25
0
        public void GetFavoriteParkBySurveyCountTest() //Dictionary<string, int> GetFavoriteParkBySurveyCount()
        {
            //Arrange
            ISurveyDAL surveySqlDAL = new SurveySqlDAL(connectionString);

            //ACT
            int count = 0; //count number of surveys per park entry
            Dictionary <string, int> surveys = surveySqlDAL.GetFavoriteParkBySurveyCount();

            foreach (KeyValuePair <string, int> survey in surveys)
            {
                count += survey.Value;
            }

            //Assert
            Assert.IsNotNull(surveys, "Favorite surveys list is empty!");
            Assert.AreEqual(surveyCount, count, $"Expected a count of {surveyCount} for parks.");
        }
Ejemplo n.º 26
0
        public void SurveySqlDAL_AddNewSurvey_Tests()
        {
            //Arrange
            SurveySqlDAL surveyDAL = new SurveySqlDAL();

            //Survey newSurvey = new Survey();
            //newSurvey.ActivityLevel = "test";
            //newSurvey.EmailAddress = "test";
            //newSurvey.State = "test";
            //newSurvey.ParkCode = "ENP";
            ////Act
            //bool successAdding = surveyDAL.addNewSurvey(newSurvey);

            //Assert
            //Assert.IsTrue(successAdding);
            Assert.IsNotNull(surveyDAL);
            Assert.AreEqual(1, rowAffected);
        }
Ejemplo n.º 27
0
        public void SubmitSurveyTest()
        {
            //Arrange
            SurveySqlDAL surveyDal = new SurveySqlDAL(connectionString);
            Survey       survey    = new Survey
            {
                Email         = "*****@*****.**",
                ParkCode      = "TST2",
                State         = "Ohio",
                ActivityLevel = "active"
            };

            //Act
            bool didWork = surveyDal.SubmitSurvey(survey);

            //Assert
            Assert.AreEqual(true, didWork);
        }
Ejemplo n.º 28
0
        public void SubmitSurveyTest()
        {
            //Arrange
            SurveySqlDAL surveySqlDAL = new SurveySqlDAL(connectionString);
            SurveyForm   model        = new SurveyForm()
            {
                ParkCode      = "gnp",
                EmailAddress  = "*****@*****.**",
                State         = "test",
                ActivityLevel = "test"
            };

            //Act
            bool didWork = surveySqlDAL.SubmitSurvey(model);

            //Assert
            Assert.AreEqual(true, didWork);
        }
Ejemplo n.º 29
0
        public ActionResult AddSurvey(Survey model, string id)
        {
            ViewBag.visable = "hidden";
            if (!ModelState.IsValid)
            {
                ViewBag.visable = "";
                return(View("AddSurvey"));
            }
            ISurveyDAL newSurvey = new SurveySqlDAL();

            model.ParkCode = id;
            if (newSurvey.addNewSurvey(model))
            {
                return(RedirectToAction("SurveyList", "Survey"));
            }
            else
            {
                return(View("AddSurvey"));
            }
        }
        public void HomeController_SurveySubmitAction_RedirectToIndexView()
        {
            //Arrange
            SurveySqlDAL     mockDal    = new SurveySqlDAL(connectionString);
            SurveyController controller = new SurveyController();
            SurveyForm       model      = new SurveyForm()
            {
                ParkCode      = "gnp",
                EmailAddress  = "*****@*****.**",
                State         = "test",
                ActivityLevel = "test"
            };

            //Act
            mockDal.SubmitSurvey(model);
            RedirectToRouteResult result = controller.SurveySubmit(model) as RedirectToRouteResult;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("Index", result.RouteValues["action"]);
        }