public void TakeSurvey() { // Arrange SurveyController controller = new SurveyController(); // Act ViewResult result = controller.TakeSurvey() as ViewResult; // Assert Assert.IsNotNull(result); }
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)); }