예제 #1
0
        public void AMessageIsProvidedForUser()
        {
            _voter = new StoryVoter();
            var result = _voter.AddVote(_story.ID);

            var result2 = _voter.AddVote(_story.ID);

            Assert.False(result2.VoteSucceeded);
            Assert.Equal("Only 1 vote per story allowed every 10 seconds :-)", result2.Message);
        }
예제 #2
0
        public void RatingIsNotIncrementedBy1()
        {
            _voter = new StoryVoter();
            var result = _voter.AddVote(_story.ID);

            Assert.Equal(1, result.Story.Rating);

            var result2 = _voter.AddVote(_story.ID);

            Assert.Equal(1, result2.Story.Rating);
        }
예제 #3
0
        public void AMessageIsProvidedForUser()
        {
            _voter = new StoryVoter();
            var result = _voter.AddVote(_story.ID);

            Assert.Equal("Thank you for voting!", result.Message);
            Assert.Equal(true, result.VoteSucceeded);
        }
예제 #4
0
        public ActionResult Vote(int?storyID, string sortOrder = "ratingDescending")
        {
            var sv     = new StoryVoter();
            var result = sv.AddVote(storyID);

            // Display success or fail message of voting
            return(RedirectToAction("Index", "Home", new { sortOrder = sortOrder, message = result.Message }));
        }