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 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 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 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); }