Example #1
0
 public void Should_Kingdom_WhenTwoCompetingKingdomGetZeroAllies()
 {
     //when
     ballotSystem = new BallotSystem(competing, kingdoms, new RandomizeMessage(new InMemoryMessageSource()), 6);
     Assert.IsTrue(ballotSystem.IsReElectionRequired());
     ballotSystem.AddMessageToBallot(competing[2], kingdoms[5], "Gorilla");
     ballotSystem.SendMessageToKingdom();
     //then
     Assert.AreEqual(competing[2], ballotSystem.GetKingdomWithMaxAllies());
     Assert.AreEqual(1, ballotSystem.GetKingdomWithMaxAllies().GetAlliesCount());
 }
Example #2
0
        public void Should_False_Tie()
        {
            ballotSystem.AddMessageToBallot(competing[0], kingdoms[3], "Owl");
            ballotSystem.AddMessageToBallot(competing[1], kingdoms[4], "Dragon");
            ballotSystem.AddMessageToBallot(competing[1], kingdoms[5], "Gorilla");
            ballotSystem.SendMessageToKingdom();

            Assert.AreEqual(3, ballotSystem.BallotMessageCount());
            Assert.AreEqual(1, competing[0].GetAlliesCount());
            Assert.AreEqual(2, competing[1].GetAlliesCount());
            Assert.AreEqual(false, ballotSystem.IsTie());
            Assert.AreEqual(competing[1], ballotSystem.GetKingdomWithMaxAllies());
            Assert.AreEqual(competing[1].GetAlliesCount(), ballotSystem.GetKingdomWithMaxAllies().GetAlliesCount());
        }
Example #3
0
        public void Should_True_ReElectionRequiredIfOneKingdomCompetingAndGotZeroAllies()
        {
            ballotSystem = new BallotSystem(new List <Kingdom>()
            {
                kingdoms[0]
            }, kingdoms);
            ballotSystem.AddMessageToBallot(competing[0], kingdoms[3], "xxxxx");
            ballotSystem.SendMessageToKingdom();

            Assert.IsTrue(ballotSystem.IsReElectionRequired());

            ballotSystem.ReElectionSetup();
            ballotSystem.AddMessageToBallot(competing[0], kingdoms[3], "Owl");
            ballotSystem.SendMessageToKingdom();
            Assert.AreEqual(competing[0], ballotSystem.GetKingdomWithMaxAllies());
            Assert.AreEqual(1, ballotSystem.GetKingdomWithMaxAllies().GetAlliesCount());
        }