Ejemplo n.º 1
0
        public void DeleteAnswer_Not_Found()
        {
            var c      = ControllerProvider.CreateQuizzesController();
            var result = c.DeleteAnswer(-1) as HttpStatusCodeResult;

            Assert.AreEqual(result.StatusCode, new HttpStatusCodeResult(HttpStatusCode.NotFound).StatusCode);
        }
Ejemplo n.º 2
0
        public void DeleteAnswer_Bad_Request()
        {
            var c      = ControllerProvider.CreateQuizzesController();
            var result = c.DeleteAnswer(null) as HttpStatusCodeResult;

            Assert.AreEqual(result.StatusCode, new HttpStatusCodeResult(HttpStatusCode.BadRequest).StatusCode);
        }
Ejemplo n.º 3
0
        public void DeleteAnswer()
        {
            var c      = ControllerProvider.CreateQuizzesController();
            var result = c.DeleteAnswer(1) as PartialViewResult;
            var model  = result.Model as EditQuestionViewModel;

            Assert.IsNotNull(model);
        }
Ejemplo n.º 4
0
        public void CreateAnswer_Get()
        {
            var c      = ControllerProvider.CreateQuizzesController();
            var result = c.CreateAnswer(1) as RedirectToRouteResult;

            Assert.AreEqual(result.RouteValues["action"], "EditQuestion");
            Assert.AreEqual(result.RouteValues["id"], 1);
        }
Ejemplo n.º 5
0
        public void Delete()
        {
            var c      = ControllerProvider.CreateQuizzesController();
            var result = c.Delete(1) as ViewResult;
            var model  = result.Model as QuizViewModel;

            Assert.IsNotNull(model);
        }
Ejemplo n.º 6
0
        public void Edit_Not_Found()
        {
            var c = ControllerProvider.CreateQuizzesController();

            HttpStatusCodeResult result;

            result = c.Edit(-1) as HttpStatusCodeResult;

            Assert.AreEqual(result.StatusCode, new HttpStatusCodeResult(HttpStatusCode.NotFound).StatusCode);
        }
Ejemplo n.º 7
0
        public void Edit_Bad_Request()
        {
            var c = ControllerProvider.CreateQuizzesController();

            HttpStatusCodeResult result;

            result = c.Edit((int?)null) as HttpStatusCodeResult;

            Assert.AreEqual(result.StatusCode, new HttpStatusCodeResult(HttpStatusCode.BadRequest).StatusCode);
        }
Ejemplo n.º 8
0
        public void Edit_Get()
        {
            var c = ControllerProvider.CreateQuizzesController();

            var result = c.Edit(1) as ViewResult;
            var model  = result.Model as EditQuizViewModel;

            Assert.IsNotNull(model);
            Assert.AreEqual(1, model.Quiz.QuizId);
        }
Ejemplo n.º 9
0
        public void EditAnswer_Get()
        {
            var c = ControllerProvider.CreateQuizzesController();

            var result = c.EditAnswer(1) as PartialViewResult;
            var model  = result.Model as EditAnswerViewModel;

            Assert.IsNotNull(model);
            Assert.AreEqual(1, model.Answer.AnswerId);
        }
Ejemplo n.º 10
0
        public void EditAnswer_Post()
        {
            var    c     = ControllerProvider.CreateQuizzesController();
            Answer model = Mocks.AnswerRepo.Get(1);



            var result = c.EditAnswer(Mocks.ModelConverter.ToEditAnswerViewModel(model)) as RedirectToRouteResult;

            Assert.AreEqual(result.RouteValues["action"], "EditQuestion");
        }
Ejemplo n.º 11
0
        public void EditQuestion_Post()
        {
            var c = ControllerProvider.CreateQuizzesController();
            EditQuestionViewModel model = Mocks.ModelConverter.ToEditQuestionViewModel(Mocks.QuestionRepo.Get(1));

            model.Question.Text = "text";

            var result = c.EditQuestion(model) as PartialViewResult;

            model = result.Model as EditQuestionViewModel;

            Assert.IsNotNull(model);
            Assert.AreEqual("text", model.Question.Text);
        }
Ejemplo n.º 12
0
        public void Edit_Post()
        {
            var c = ControllerProvider.CreateQuizzesController();
            EditQuizViewModel model = Mocks.ModelConverter.ToEditQuizViewModel(Mocks.QuizService.Get(1));

            model.Quiz.Name = "test";

            var result = c.Edit(model) as PartialViewResult;

            model = result.Model as EditQuizViewModel;

            Assert.IsNotNull(model);
            Assert.AreEqual("test", model.Quiz.Name);
        }
Ejemplo n.º 13
0
        public void Index()
        {
            var c = ControllerProvider.CreateQuizzesController();


            QuizzesViewModel model;
            ViewResult       result;

            result = c.Index("", null, null) as ViewResult;
            model  = result.Model as QuizzesViewModel;

            Assert.IsNotNull(model);
            Assert.AreEqual(2, model.Quizzes.Count());
            Assert.AreEqual(3, model.QuizCategories.Count());

            result = c.Index("***", null, null) as ViewResult;
            model  = result.Model as QuizzesViewModel;
            Assert.AreEqual(0, model.Quizzes.Count());

            result = c.Index("q", null, null) as ViewResult;
            model  = result.Model as QuizzesViewModel;
            Assert.AreEqual(2, model.Quizzes.Count());
        }