Exemplo n.º 1
0
        public async Task <IActionResult> Edit(OpenAnswerQuestionModel modelForView)
        {
            OpenAnswerQuestion question = await _db.OpenAnswerQuestions.FirstOrDefaultAsync(p => p.Id == modelForView.Id);

            question.UpdateQuestion(modelForView.Question, modelForView.Answer);
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index", "Home"));
        }
        public void UpdateQuestion_ChangesTextAndAnswer()
        {
            //arrange

            string expectedQuestion = "What year was epam founded?";
            string expectedAnswer   = "1993";

            //act

            OpenAnswerQuestion question = new OpenAnswerQuestion("", "");

            question.UpdateQuestion(expectedQuestion, expectedAnswer);

            //Assert

            Assert.Equal(expectedQuestion, question.Text);
            Assert.Equal(expectedAnswer, question.Answer);
        }