public void ShouldBeAbleToGetTheQuestionText() { string questionText = "What is the use of 'var' key word?"; User user = new User("shanu","shanu","*****@*****.**"); Question question = new Question(questionText,user); Assert.AreEqual(questionText,question.QuestionText); }
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); }
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); }
public void ShouldBeAbleToCreateQuestionWithTag() { string questionText = "What is the use of 'var' key word?"; Tag csharpTag = new Tag("C#"); Tag javaTag = new Tag("Java"); User user = new User("shanu", "shanu", "*****@*****.**"); Question question = new Question(questionText,user); question.AddTags(csharpTag); question.AddTags(javaTag); Assert.AreEqual(csharpTag, question.Tags[0]); Assert.AreEqual(javaTag, question.Tags[1]); }
public void ShouldBeAbleToSearchQuestionsBasedOnAKeyword() { string questionText = "What is the use of 'var' key word?"; string searchString = "word"; User user = UserMother.Kamal; Question question = new Question(questionText, user); Repository repository = Repository.GetInstance(); int count = repository.SearchKeyWordInQuestion(searchString).Count; repository.SaveUser(user); repository.SaveQuestion(question); IList<Question> questionsFound = repository.SearchKeyWordInQuestion(searchString); Assert.AreEqual(count + 1,questionsFound.Count); }
public virtual bool Equals(Question other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.askedOn, askedOn) && Equals(other.user, user) && Equals(other.text, text) && Equals(other.tags, tags) && Equals(other.answers, answers); }
public virtual void AcceptAnswer(Question question,Answer answer) { if (!question.IsOwner(this)) throw new NotSupportedException("An answer can be accepted only by the question's owner"); question.AcceptSolution(answer); }