コード例 #1
0
ファイル: QuestionTest.cs プロジェクト: karthikbv/askme
 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);
 }
コード例 #2
0
ファイル: QuestionTest.cs プロジェクト: karthikbv/askme
        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);
        }
コード例 #3
0
ファイル: QuestionTest.cs プロジェクト: karthikbv/askme
 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);
 }
コード例 #4
0
ファイル: QuestionTest.cs プロジェクト: karthikbv/askme
        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]);
        }
コード例 #5
0
ファイル: QuestionTest.cs プロジェクト: karthikbv/askme
        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);
        }
コード例 #6
0
ファイル: Question.cs プロジェクト: bagheera/askme
 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);
 }
コード例 #7
0
ファイル: User.cs プロジェクト: bagheera/askme
 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);
 }