public void AnswerKnowsTheUserWhoAnswered() { const string userName = "******"; User user = new User(userName, "******", "*****@*****.**"); Answer answer = new Answer(new AskMeDate(), user, ""); Assert.AreEqual(user, answer.User); }
public void VerifyAnswerInsertion() { User user = new User("PakodaSingh", "******", "*****@*****.**"); user.UserId = 1; Repository repository = Repository.GetInstance(); repository.SaveUser(user); Answer answer = new Answer(new AskMeDate(), user, ""); repository.SaveAnswer(answer); }
public virtual bool Equals(Answer other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Equals(other.createdOn, createdOn) && Equals(other.user, user) && Equals(other.text, text) && other.answerId == answerId; }
public void AnswerShouldReturnNumberOfVotes() { User user = new User("user1", "123", "*****@*****.**"); AnswerVote vote = AnswerVote.PositiveVote(user); User userWhoAnswered = new User("Answerer", "123", "*****@*****.**"); Answer answer = new Answer(new AskMeDate(), userWhoAnswered, "Dummy answer"); answer.CastVote(vote); Assert.AreEqual(1, answer.Votes.Count); }
public void AnswererShouldGetTenPointsOnReceivingPositiveVote() { User user = new User("user1", "123", "*****@*****.**"); AnswerVote vote = AnswerVote.PositiveVote(user); User userWhoAnswered = new User("Answerer", "123", "*****@*****.**"); Answer answer = new Answer(new AskMeDate(), userWhoAnswered, "Dummy answer" ); answer.CastVote(vote); Assert.AreEqual(10, userWhoAnswered.Points()); }
public void OneUserCanOnlyCastOneVoteForAnAnswer() { User userWhoAnswered = new User("Answerer", "123", "*****@*****.**"); Answer answer = new Answer(new AskMeDate(), userWhoAnswered, "Dummy answer"); User user = new User("user1", "123", "*****@*****.**"); AnswerVote vote = AnswerVote.PositiveVote(user); answer.CastVote(vote); Assert.IsTrue(answer.Votes.HasUserVoted(user)); answer.CastVote(vote); //this should throw an exception }
public virtual void AcceptSolution(Answer answer) { lock (localLock) { if (acceptedAnswer == null) { acceptedAnswer = answer; AssignPointForAcceptingAnswer(); } else { throw new NotSupportedException("An answer has been already accepted"); } } }
public void IfUserAndDateAndTextAreSameThenAnswersAreEqual() { Answer answer1 = new Answer(new AskMeDate(), UserMother.Kamal, "this is good answer"); Answer answer2 = new Answer(new AskMeDate(), UserMother.Kamal, "this is good answer"); Assert.AreEqual(answer1, answer2); }
public void AnswerShouldHaveText() { const string answerText = "This was supposed to be a funny answer but Chandra couldn't come up with one"; Answer answer = new Answer(new AskMeDate(), null, answerText); Assert.AreSame(answerText, answer.ToString()); }
public void AnswerKnowsWhenItWasCreated() { AskMeDate time = new AskMeDate(); Answer answer = new Answer(time, null, ""); Assert.AreEqual(time, answer.CreatedOn); }
public void AddAnswer(Answer answer) { answers.Add(answer); }
public virtual void AddAnswer(Answer answer) { answers.AddAnswer(answer); }
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); }
public void ShouldBeAbleToSaveAndRetrieveVotesInAnswer() { User user = UserMother.Kamal; Answer answer = new Answer(new AskMeDate(), user, "answer to be voted"); Repository repository = Repository.GetInstance(); repository.SaveUser(user); AnswerVote vote = AnswerVote.NegativeVote(user); answer.CastVote(vote); repository.SaveAnswer(answer); repository.Evict(answer); string searchString = "answer to be voted"; IList<Answer> answersFound = repository.SearchKeyWordInAnswers(searchString); Assert.AreEqual(1, answersFound.Count); Assert.AreEqual(1, answersFound[0].Votes.Count); }
public void UserShouldBeAbleCastNegativeVote() { User userWhoAnswered = new User("Answerer", "123", "*****@*****.**"); Answer answer = new Answer(new AskMeDate(), userWhoAnswered, "Dummy answer"); User user = new User("user1", "123", "*****@*****.**"); AnswerVote vote = AnswerVote.NegativeVote(user); answer.CastVote(vote); }