Esempio n. 1
0
 public void CalculateFundingWinnerTest()
 {
     Voter v1 = new Voter("rep1");
     Voter v2 = new Voter("rep2");
     Voter v3 = new Voter("rep3");
     PolicyCategory pc = new PolicyCategory("test");
     var fundingOptions = new List<FundingOption>
     {
         new FundingOption("op1", 1, FundingType.ImportTax),
         new FundingOption("op2", 1, FundingType.IncomeTax),
         new FundingOption("op3", 1, FundingType.InheritanceTax)
     };
     Policy pol = new Policy(pc, "pol1", 1);
     var pref1 = new FundingVote(fundingOptions[0], 1);
     var pref2 = new FundingVote(pref1);
     pref2.AddOption(fundingOptions[2], fundingOptions[0]);
     var pref3 = new FundingVote(pref1);
     pref3.AddOption(fundingOptions[1], null);
     PolicyVote vote1 = new PolicyVote(pc, pol, 1, pref1);
     PolicyVote vote2 = new PolicyVote(pc, pol, 1, pref2);
     PolicyVote vote3 = new PolicyVote(pc, pol, 1, pref3);
     v1.Vote(vote1);
     v2.Vote(vote2);
     v3.Vote(vote3);
     Assert.AreEqual(fundingOptions[0], pc.CalculateWinner().Funding);
 }
Esempio n. 2
0
 public void CalculatePolicyWinnerTest()
 {
     PolicyCategory pc = new PolicyCategory("test1");
     Policy pol = new Policy(pc, "pol", 1);
     Policy pol1 = new Policy(pc, "pol1", 1);
     Policy pol2 = new Policy(pc, "pol2", 1);
     Voter v1 = new Voter("rep1");
     Voter v2 = new Voter("rep2");
     Voter v3 = new Voter("rep3");
     Voter v4 = new Voter("rep4");
     var fo = new FundingOption("op1", 1, FundingType.ImportTax);
     var vote1 = new PolicyVote(pc, pol1, 2, fo);
     var vote2 = new PolicyVote(pc, pol2, 1, fo);
     var vote3 = new PolicyVote(pc, pol2, 1, fo);
     var vote4 = new PolicyVote(pc, pol, 1, fo);
     vote4.AddPolicy(pol1, fo);
     v1.Vote(vote1);
     v2.Vote(vote2);
     v3.Vote(vote3);
     v4.Vote(vote4);
     Assert.AreEqual(pol1, pc.CalculateWinner());
 }
Esempio n. 3
0
 /// <summary>
 /// Method to vote for a given policy with a given set of preferences
 /// </summary>
 /// <param name="v">the vote to cast</param>
 public void Vote(PolicyVote v)
 {
     if (v.Weight > this.CurrentPoints)
         throw new Exception("Voter attempted to vote with more points than they had");
     v.Cast();
 }
Esempio n. 4
0
 /// <summary>
 /// Take a vote for this policy
 /// </summary>
 /// <param name="v">The vote to cast</param>
 public void AddVote(PolicyVote v)
 {
     this.Votes.Add(v);
 }