public void NewQuestionReturnsNewQuestionInTheModel() { using (var controller = new SurveysController(null, null, null, null, null, null)) { controller.TempData[SurveysController.CachedSurvey] = new Survey(); var result = controller.NewQuestion(new Survey()) as ViewResult; var model = result.ViewData.Model as TenantPageViewData<Question>; Assert.IsInstanceOfType(model.ContentModel, typeof(Question)); } }
public void NewQuestionReturnsNewQuestionAsTitleInTheModel() { using (var controller = new SurveysController(null, null, null, null, null, null)) { controller.TempData[SurveysController.CachedSurvey] = new Survey(); var result = controller.NewQuestion(new Survey()) as ViewResult; var model = result.ViewData.Model as TenantMasterPageViewData; Assert.AreSame("New Question", model.Title); } }
public void NewQuestionRedirectToTheNewActionWhenCachedSurveyIsNull() { using (var controller = new SurveysController(new Mock<ISurveyStore>().Object, null, null, null, null, null)) { controller.TempData[SurveysController.CachedSurvey] = null; var result = controller.NewQuestion(new Survey()) as RedirectToRouteResult; Assert.AreEqual("New", result.RouteValues["action"]); Assert.AreEqual(null, result.RouteValues["controller"]); } }
public void NewQuestionReturnsEmptyViewName() { using (var controller = new SurveysController(null, null, null, null, null, null)) { controller.TempData[SurveysController.CachedSurvey] = new Survey(); var result = controller.NewQuestion(new Survey()) as ViewResult; Assert.AreEqual(string.Empty, result.ViewName); } }
public void NewQuestionCopiesSurveyTitleToCachedSurveyThatIsReturnedInViewData() { var survey = new Survey { Title = "title" }; using (var controller = new SurveysController(null, null, null, null, null, null)) { controller.TempData[SurveysController.CachedSurvey] = new Survey(); var result = controller.NewQuestion(survey) as ViewResult; var cachedSurvey = result.TempData[SurveysController.CachedSurvey] as Survey; Assert.AreSame(survey.Title, cachedSurvey.Title); } }