public void TestSurveyResults()
        {
            // Arrange
            ParkMockDAO      parkDAO    = new ParkMockDAO();
            SurveyMockDAO    surveyDAO  = new SurveyMockDAO();
            SurveyController controller = new SurveyController(parkDAO, surveyDAO);

            // Act
            Survey newSurvey = new Survey()
            {
                ParkCode         = "YOSE",
                Email            = "*****@*****.**",
                ActivityLevel    = "Active",
                StateOfResidence = "California",
            };

            surveyDAO.SaveSurvey(newSurvey);
            IActionResult result = controller.SurveyResults();

            // Assert
            ViewResult vr = result as ViewResult;

            Assert.IsNotNull(vr, "SurveyResults did not return a View");

            IList <SurveyResult> surveyResults = vr.Model as IList <SurveyResult>;

            Assert.IsNotNull(surveyResults, "ViewResult.Model is not an IList<SurveyResult>");
            Assert.AreEqual(4, surveyResults.Count);
        }
예제 #2
0
        public void SurveyController()
        {
            //Survey controller test
            var sC = new SurveyController(surveyDAL, parkDAL);

            //Index Action should return index view
            var index = sC.Index() as ViewResult;

            Assert.AreEqual("Index", index.ViewName);

            //SurveyResults action should return Surveyresults
            var surveyResult = sC.SurveyResults() as ViewResult;

            Assert.AreEqual("SurveyResults", surveyResult.ViewName);
        }