CastVote() public méthode

public CastVote ( AnswerVote vote ) : void
vote AnswerVote
Résultat void
Exemple #1
0
        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
        }
Exemple #2
0
        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());
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }