public void TestExplicitCreation3()
 {
     var p = new Person(2, 0, 1);
     Assert.AreEqual(1, p.Ranking(0), "Rank of 0");
     Assert.AreEqual(0, p.Ranking(1), "Rank of 1");
     Assert.AreEqual(2, p.Ranking(2), "Rank of 2");
 }
 public void TestExplicitCreation1()
 {
     var p = new Person(0);
     Assert.AreEqual(1, p.FullRanking().Count(), "single candidate, not ranked");
     Assert.AreEqual(0, p.FullRanking().First().candidate, "first candidate");
     Assert.AreEqual(0, p.FullRanking().First().ranking, "first candidate ranking");
     Assert.AreEqual(0, p.Ranking(0), "first candidate direct ranking");
 }
 public void TestExplicitCreate1Bad()
 {
     var p = new Person(0);
     p.Ranking(1);
 }
 public void TestRankingOutOfBounds()
 {
     int count = 10;
     var p = new Person(count, new Random());
     var r = p.Ranking(count + 1);
 }
 public void TestRankingOK()
 {
     int count = 10;
     var p = new Person(count, new Random());
     var seen = new SortedSet<int>();
     foreach (var candidate in Enumerable.Range(0, 10))
     {
         var r = p.Ranking(candidate);
         Assert.IsFalse(seen.Contains(r), "Duplicate ranking");
         seen.Add(r);
         Console.WriteLine("Candiate {0} has rank {1}.", candidate, r);
     }
     Assert.AreEqual(count, seen.Count, "Size of the count");
 }
        public void TestFullRankingWithOneGone2()
        {
            var p = new Person(2, 1, 0);
            Assert.AreEqual(0, p.Ranking(0), "Rank for 0");
            Assert.AreEqual(2, p.Ranking(2), "Rank for 0");
            var ranking = p.FullRanking(1).ToArray();
            Assert.AreEqual(2, ranking.Length, "# of ranked outputs");

            var c0 = ranking.Where(c => c.candidate == 0).First().ranking;
            var c2 = ranking.Where(c => c.candidate == 2).First().ranking;

            Assert.AreEqual(0, c0, "Ranking for candidate 0");
            Assert.AreEqual(1, c2, "Ranking for candidate 2");
        }