public void SurveyAction_ReturnsCorrectView() { //Arrange SurveyBodyDouble fakeDal = new SurveyBodyDouble(); SurveyController controller = new SurveyController(fakeDal); Survey fakeSurvey = new Survey(); //Act //ActionResult result = controller.SurveyResult(fakeSurvey); //Assert //Test to see if result is of type ViewResult //Assert.IsTrue(result.GetType() == typeof(ViewResult)); //Cast result into a ViewResult //ViewResult vr = (ViewResult)result; //Assert.AreEqual("SurveyResult", vr.ViewName); //<-- check the name of the view }
public void TakeSurveyAction_ReturnsCorrectViewAndModel() { //Arrange SurveyBodyDouble fakeDal = new SurveyBodyDouble(); SurveyController controller = new SurveyController(fakeDal); //Act ActionResult result = controller.TakeSurvey(); //Assert //Test to see if result is of type ViewResult Assert.IsTrue(result.GetType() == typeof(ViewResult)); //Cast result into a ViewResult ViewResult vr = (ViewResult)result; Assert.AreEqual("TakeSurvey", vr.ViewName); //<-- check the name of the view // Check if the model is a Survey, not anything else Assert.IsTrue(vr.Model.GetType() == typeof(Survey)); }