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