Exemplo n.º 1
0
        public void Voteable_CannotRevokeNonExistingVote_Throws()
        {
            // Arrange
            var target     = new QuestionBuilder().SetupValidQuestion().Build();
            var limits     = new LimitsBuilder().Build();
            var firstVote  = new VoteBuilder(target).SetupValidUpvote().ByOneUser().Build();
            var secondVote = new VoteBuilder(target).SetupValidUpvote().ByAnotherUser().Build();

            target.ApplyVote(firstVote);

            // Act, Assert
            Assert.Throws <BusinessException>(() => target.RevokeVote(secondVote, limits));
        }
Exemplo n.º 2
0
        public void Voteable_CanRevokeVoteWithinDeadline_Successfully()
        {
            // Arrange
            var target = new QuestionBuilder().SetupValidQuestion().Build();
            var vote   = new VoteBuilder(target).SetupValidUpvote().ByOneUser().Build();
            var limits = new LimitsBuilder().Build();

            target.ApplyVote(vote);

            // Act
            target.RevokeVote(vote, limits);

            // Assert
            Assert.Equal(0, target.VotesSum);
        }
Exemplo n.º 3
0
        public void Voteable_CannotRevokeVoteOutsideDeadline_Successfully()
        {
            // Arrange
            var target    = new QuestionBuilder().SetupValidQuestion().Build();
            var limits    = new LimitsBuilder().Build();
            var firstVote = new VoteBuilder(target)
                            .SetupValidUpvote()
                            .ByOneUser()
                            .MakeTimeGoBy()
                            .Build();

            target.ApplyVote(firstVote);

            // Act, Assert
            Assert.Throws <BusinessException>(() => target.RevokeVote(firstVote, limits));
        }