Exemplo n.º 1
0
        public void TestUpdateQuizAnswer()
        {
            BoraNowSeeder.Seed();
            var qabo       = new QuizAnswerBusinessObject();
            var qqbo       = new QuizQuestionBusinessObject();
            var quizbo     = new QuizBusinessObject();
            var resList    = qabo.List();
            var quizAnswer = resList.Result.FirstOrDefault();


            var newQuiz         = new Quiz("Where you wanna go?");
            var newQuizQuestion = new QuizQuestion("Where you wanna go?", newQuiz.Id);

            quizbo.Create(newQuiz);
            qqbo.Create(newQuizQuestion);

            quizAnswer.QuizQuestionId = newQuizQuestion.Id;
            quizAnswer.Answer         = "yes";

            var resUpdate = qabo.Update(quizAnswer);

            resList = qabo.List();

            Assert.IsTrue(resUpdate.Success && resList.Success && resList.Result.First().Answer == "yes" &&
                          resList.Result.First().QuizQuestionId == newQuizQuestion.Id);
        }
Exemplo n.º 2
0
        public ActionResult Create([FromBody] QuizQuestionViewModel vm)
        {
            var c = new QuizQuestion(vm.Question, vm.QuizId);

            var res  = _bo.Create(c);
            var code = res.Success ? HttpStatusCode.OK : HttpStatusCode.InternalServerError;

            return(new ObjectResult(code));
        }
Exemplo n.º 3
0
        public void TestCreateQuizQuestion()
        {
            BoraNowSeeder.Seed();
            var qqbo = new QuizQuestionBusinessObject();
            var qbo  = new QuizBusinessObject();

            var quiz = new Quiz("This quiz rocks");

            qbo.Create(quiz);

            var quizQuestion = new QuizQuestion("do u like wine?", quiz.Id);

            var resCreate = qqbo.Create(quizQuestion);
            var resGet    = qqbo.Read(quizQuestion.Id);

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Exemplo n.º 4
0
        public void TestCreateQuizAnswerAsync()
        {
            BoraNowSeeder.Seed();
            var qabo   = new QuizAnswerBusinessObject();
            var qqbo   = new QuizQuestionBusinessObject();
            var quizbo = new QuizBusinessObject();

            var newQuiz         = new Quiz("Where you wanna go?");
            var newQuizQuestion = new QuizQuestion("Where you wanna go?", newQuiz.Id);

            quizbo.Create(newQuiz);
            qqbo.Create(newQuizQuestion);

            var newQuizAnswer = new QuizAnswer("Beach", newQuizQuestion.Id);

            var resCreate = qabo.CreateAsync(newQuizAnswer).Result;
            var resGet    = qabo.ReadAsync(newQuizAnswer.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }