예제 #1
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.");
        }
예제 #2
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.");
        }