public async void RunSimpleElectionSetWithNoFlip() { var e = new Election() { NumberOfCandidates = 2, NumberOfPeople = 2 }; var step1 = new ElectionDriver.Fakes.StubIElectionStep(); step1.RunStepPersonArrayCandiateRankingArrayArray = (people, prev) => { return new CandiateRanking[] { new CandiateRanking(0, 1) }; }; e.AddStep(step1); var flips = await e.RunElection(); Assert.AreEqual(0, flips.flips, "Expected # of flips"); }
public async void RunSimpleElectionSetWithFlip() { var e = new Election() { NumberOfCandidates = 2, NumberOfPeople = 2 }; var step1 = new ElectionDriver.Fakes.StubIElectionStep(); bool firstcall = true; step1.RunStepPersonArrayCandiateRankingArrayArray = (people, prev) => { if (firstcall) { firstcall = false; return new CandiateRanking[] { new CandiateRanking(0, 1) }; } else { var p1 = people.First(); Assert.AreEqual(1, p1.NumberOfCandidates, "# of candidates on second sub-election"); Assert.AreEqual(0, p1.FullRanking().First().candidate, "Kept candidate"); return new CandiateRanking[] { new CandiateRanking(1, 1) }; } }; e.AddStep(step1); var flips = await e.RunElection(); Assert.AreEqual(1, flips.flips, "Expected # of flips"); Assert.AreEqual(1, flips.candidateOrdering.Length, "# of rnaking candidates"); Assert.AreEqual(0, flips.candidateOrdering[0], "Candidate order 0"); }