public void TestCompose(double[] votes, int seats) { Party[] parties = votes.Select(x => new Party(x)).ToArray(); int result = SaintLague.Calculate(parties, seats); Assert.AreEqual(seats, result); Assert.AreEqual(seats, parties.Sum(x => x.Seats)); }
public void TestArgumentOutOfRange(double[] votes, int seats) { Party[] parties = votes.Select(x => new Party(x)).ToArray(); Assert.ThrowsException <ArgumentOutOfRangeException>(() => SaintLague.Calculate(parties, seats)); }
public void TestArgumentNull() { Assert.ThrowsException <ArgumentNullException>(() => SaintLague.Calculate(null, 0)); Assert.ThrowsException <ArgumentNullException>(() => SaintLague.Calculate(new SaintLague.IParty[] { new Party(0.3), null }, 0)); }