예제 #1
0
        public void AllSpoiled_Test()
        {
            var dupPersonGuid = Guid.NewGuid();

            var votes = new List <VoteInfo>
            {
                new VoteInfo {
                    PersonIneligibleReasonGuid = Guid.NewGuid(), VoteId = 1
                },
                new VoteInfo {
                    VoteIneligibleReasonGuid = Guid.NewGuid(), VoteId = 2
                },
                new VoteInfo {
                    PersonIneligibleReasonGuid = Guid.NewGuid(), VoteId = 3
                },
            };

            VoteAnalyzer.UpdateAllStatuses(votes,
                                           votes.Select(v => new Vote {
                C_RowId = v.VoteId
            }).ToList(),
                                           new Savers(new TestDbContext()).VoteSaver);

            var model = new BallotAnalyzer(3, false);

            string newStatus;
            int    spoiledCount;

            model.DetermineStatusFromVotesList(BallotStatusEnum.Ok, votes, out newStatus, out spoiledCount)
            .ShouldEqual(false);

            newStatus.ShouldEqual(BallotStatusEnum.Ok);
            spoiledCount.ShouldEqual(3);
        }
예제 #2
0
        public void HasDuplicates2_KeepStatusCode_Test()
        {
            var votes = new List <VoteInfo>
            {
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
            };


            var model = new BallotAnalyzer(3, false);

            string newStatus;

            // keep Review
            int spoiledCount;

            model.DetermineStatusFromVotesList(BallotStatusEnum.Review, votes, out newStatus, out spoiledCount)
            .ShouldEqual(false);
            newStatus.ShouldEqual(BallotStatusEnum.Review);
            spoiledCount.ShouldEqual(0);

            // override OK
            model.DetermineStatusFromVotesList(BallotStatusEnum.Ok, votes, out newStatus, out spoiledCount)
            .ShouldEqual(true);
            newStatus.ShouldEqual(BallotStatusEnum.TooFew);
            spoiledCount.ShouldEqual(0);
        }
예제 #3
0
        public void TooManyNumberOfVotesWithSpoiled_Test()
        {
            var votes = new List <VoteInfo>
            {
                new VoteInfo {
                    VoteIneligibleReasonGuid = Guid.NewGuid()
                },
                new VoteInfo {
                    VoteIneligibleReasonGuid = Guid.NewGuid()
                },
                new VoteInfo {
                    VoteIneligibleReasonGuid = Guid.NewGuid()
                },
                new VoteInfo {
                    VoteIneligibleReasonGuid = Guid.NewGuid()
                },
            };

            var model = new BallotAnalyzer(3, false);

            string newStatus;
            int    spoiledCount;

            model.DetermineStatusFromVotesList(null, votes, out newStatus, out spoiledCount).ShouldEqual(true);

            newStatus.ShouldEqual(BallotStatusEnum.TooMany);
            spoiledCount.ShouldEqual(0);
        }
예제 #4
0
        public void HasDuplicates_Test()
        {
            var dupPersonGuid = Guid.NewGuid();

            var votes = new List <VoteInfo>
            {
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
                new VoteInfo {
                    PersonGuid = dupPersonGuid
                },
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
                new VoteInfo {
                    PersonGuid = dupPersonGuid
                },
            };

            var model = new BallotAnalyzer(5, false);

            string newStatus;
            int    spoiledCount;

            model.DetermineStatusFromVotesList(BallotStatusEnum.Ok, votes, out newStatus, out spoiledCount)
            .ShouldEqual(true);

            newStatus.ShouldEqual(BallotStatusEnum.Dup);
        }
예제 #5
0
        public void CorrectNumberOfVotes_Test()
        {
            var voteInfos = new List <VoteInfo>
            {
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
            };

            var model = new BallotAnalyzer(3, false);

            string newStatus;
            int    spoiledCount;

            model.DetermineStatusFromVotesList(null, voteInfos, out newStatus, out spoiledCount).ShouldEqual(true);

            newStatus.ShouldEqual(BallotStatusEnum.Ok);
            spoiledCount.ShouldEqual(0);
        }
예제 #6
0
        public void EmptyNumberOfVotes_Test()
        {
            var votes = new List <VoteInfo>
            {
            };

            var model = new BallotAnalyzer(3, false);

            string newStatus;
            int    spoiledCount;

            model.DetermineStatusFromVotesList(null, votes, out newStatus, out spoiledCount).ShouldEqual(true);

            newStatus.ShouldEqual(BallotStatusEnum.Empty);
        }
예제 #7
0
        public void SingleIneligible_Test()
        {
            var votes = new List <VoteInfo>
            {
                new VoteInfo
                {
                    VoteIneligibleReasonGuid = IneligibleReasonEnum.Unreadable_Not_a_complete_name,
                    SingleNameElectionCount  = 4
                },
            };

            var model = new BallotAnalyzer(1, true);

            string newStatus;
            int    spoiledCount;

            model.DetermineStatusFromVotesList(null, votes, out newStatus, out spoiledCount).ShouldEqual(true);

            newStatus.ShouldEqual(BallotStatusEnum.Ok);
        }
예제 #8
0
        public void TooFewNumberOfVotesWithBlank_Test()
        {
            var votes = new List <VoteInfo>
            {
//                      new VoteInfo {VoteIneligibleReasonGuid = IneligibleReasonEnum.Unreadable_Vote_is_blank},
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
            };

            var model = new BallotAnalyzer(3, false);

            string newStatus;
            int    spoiledCount;

            model.DetermineStatusFromVotesList(null, votes, out newStatus, out spoiledCount).ShouldEqual(true);

            newStatus.ShouldEqual(BallotStatusEnum.TooFew);
            spoiledCount.ShouldEqual(0);
        }
예제 #9
0
        public void KeepReviewStatus_Test()
        {
            var votes = new List <VoteInfo>
            {
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
            };

            var model = new BallotAnalyzer(3, false);

            string newStatus;
            int    spoiledCount;

            model.DetermineStatusFromVotesList(BallotStatusEnum.Review, votes, out newStatus, out spoiledCount)
            .ShouldEqual(false);
            newStatus.ShouldEqual(BallotStatusEnum.Review);


            votes = new List <VoteInfo>
            {
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
                new VoteInfo {
                    PersonGuid = Guid.NewGuid()
                },
            };

            model.DetermineStatusFromVotesList(BallotStatusEnum.Review, votes, out newStatus, out spoiledCount)
            .ShouldEqual(false);
            newStatus.ShouldEqual(BallotStatusEnum.Review);
        }