Example #1
0
        public void Edit_LoadingNotFound()
        {
            var controller = new Wispero.Web.Controllers.QuestionController(dataService.Object, queryService.Object);
            var viewResult = controller.Edit(1);

            Assert.IsNotNull(viewResult);
            Assert.IsInstanceOfType(viewResult, typeof(RedirectResult));
            Assert.IsTrue(((RedirectResult)viewResult).Url.Contains("Error"));
        }
Example #2
0
        public void Edit_Loading()
        {
            var controller = new Wispero.Web.Controllers.QuestionController(dataService.Object, queryService.Object);
            var viewResult = controller.Edit(2);

            Assert.IsNotNull(viewResult);
            Assert.IsInstanceOfType(viewResult, typeof(ViewResult));

            var model = ((ViewResult)viewResult).Model as Models.QuesitonAndAnswerEditModel;

            Assert.IsTrue(model.Question == "Question2");
        }
Example #3
0
        public void Edit_UpdatingAttributes()
        {
            var model = new Models.QuesitonAndAnswerEditModel()
            {
                Id = 2, Answer = "Answer3", Question = "Question3", Tags = "Tag3"
            };

            var controller = new Wispero.Web.Controllers.QuestionController(dataService.Object, queryService.Object);
            var viewResult = controller.Edit(model);

            Assert.IsNotNull(viewResult);
            Assert.IsInstanceOfType(viewResult, typeof(RedirectToRouteResult));
        }
Example #4
0
        public void Edit_InvalidUpdate()
        {
            var model = new Models.QuesitonAndAnswerEditModel()
            {
                Id = 2, Answer = null, Question = "Question3", Tags = "Tag3"
            };

            var controller = new Wispero.Web.Controllers.QuestionController(dataService.Object, queryService.Object);

            controller.ModelState.AddModelError("Answer", "Answer field is required");

            var viewResult = controller.Edit(model);

            Assert.IsNotNull(viewResult);
            Assert.IsInstanceOfType(viewResult, typeof(ViewResult));

            var returnedModel = ((ViewResult)viewResult).Model as Models.QuesitonAndAnswerEditModel;

            Assert.AreSame(model, returnedModel);
        }