AddAnswer() public method

public AddAnswer ( Answer answer ) : void
answer Answer
return void
Example #1
0
        public void ShouldCollectAnswers()
        {
            User user = new User("shanu", "shanu", "*****@*****.**");
            Question question = new Question("What is the use of 'var' key word?",user);

            question.AddAnswer(new Answer(new AskMeDate(), null, "first answer"));
            Assert.AreEqual(1, question.NumberOfAnswers);
            question.AddAnswer(new Answer(new AskMeDate(), null, "second answer"));
            Assert.AreEqual(2, question.NumberOfAnswers);
        }
Example #2
0
 public void ShouldSaveAnswersToQuestion()
 {
     User user = UserMother.Kamal;
     Repository repository = Repository.GetInstance();
     repository.SaveUser(user);
     const string questionText = "What is the use of 'var' key word?";
     Question question = new Question(questionText,user);
     question.AddAnswer(new Answer(new AskMeDate(), user, "this is bad answer"));
     repository.SaveQuestion(question);
     IList<Answer> answers = repository.LoadAnswerForQuestion(question);
     Assert.AreEqual(1, answers.Count);
 }