static void Main(string[] args) { Universe universe = new Universe("Southeros"); PrintRullerAndAllies(universe); Console.WriteLine("Enter the kingdoms competing to be the ruler:"); string input = Console.ReadLine().Trim(); Console.WriteLine(); string[] kingdomsNames = input.Split(' '); List <Kingdom> competingKingDoms = new List <Kingdom>(); foreach (string name in kingdomsNames) { string nameUpperCase = name.ToUpper(); if (universe.ContainsKingdom(nameUpperCase)) { competingKingDoms.Add(universe[nameUpperCase]); } } RandomizeMessage rndMessage = new RandomizeMessage(new FileMessageSource("./boc-messages.txt")); BallotSystem ballotSystem = new BallotSystem(competingKingDoms, universe.Kingdoms, rndMessage, 6); universe.SetRandomRuller(ballotSystem); PrintRoundsResult(ballotSystem.RoundResults); PrintRullerAndAllies(universe); }
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()); }
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()); }
public BallotSystemTest() { kingdoms = new List <Kingdom>(); kingdoms.Add(new Kingdom("LAND", "Panda")); kingdoms.Add(new Kingdom("WATER", "Octopus")); kingdoms.Add(new Kingdom("ICE", "Mammoth")); kingdoms.Add(new Kingdom("AIR", "Owl")); kingdoms.Add(new Kingdom("FIRE", "Dragon")); kingdoms.Add(new Kingdom("SPACE", "Gorilla")); competing = new List <Kingdom>(); competing.Add(kingdoms[0]); competing.Add(kingdoms[1]); competing.Add(kingdoms[2]); ballotSystem = new BallotSystem(competing, kingdoms); }