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);
 }
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="source">Source for the copy</param>
 public PolicyCategory(PolicyCategory source)
 : this(source.Name)
 {
     this.Parents = new List<PolicyGraphItem>(source.Parents);
     this.policies = new Dictionary<Guid, Policy>(source.policies);
     this.Votes = new List<PolicyVote>();
 }
Exemple #3
0
 /// <summary>
 /// Constructor for Policy
 /// </summary>
 /// <param name="pc">The category that the policy will belong to</param>
 /// <param name="name">Name of the policy</param>
 /// <param name="totalCost">The CBO estimate of the policy</param>
 public Policy(PolicyCategory pc, string name, decimal totalCost) : base(name)
 {
     this.AddParent(pc);
     this.cost = totalCost;
     this.fundingVotes = new List<FundingVote>();
     pc.AddSubItem(this);
 }
Exemple #4
0
 /// <summary>
 /// Run the election, and return a graph of the winners
 /// </summary>
 /// <returns></returns>
 public PolicyCategory RunElection()
 {
     PolicyCategory final = new PolicyCategory(this.Initial);
     var policyCategories = this.Initial.GetEnumerator().OrderByDescending(x => x.TotalPoints);
     foreach (var polcat in policyCategories)
     {
         var winner = polcat.CalculateWinner();
     }
     throw new NotImplementedException();
 }
 public void Initialize()
 {
     this.pc = new PolicyCategory("parent");
     var childPc = new PolicyCategory("child1");
     var childPc2 = new PolicyCategory("child2");
     Policy pol = new Policy( childPc2, "pol1", 2);
     Policy pol2 = new Policy(childPc, "pol2", 3);
     Policy pol3 = new Policy(childPc, "pol3", 4);
     this.pc.AddSubItem(childPc);
     this.pc.AddSubItem(childPc2);
 }
 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());
 }