public void BattleSimulatorSetup()
        {
            int size = 3;

            string[] monkeyCompo = new string[] { "Flying Monkey", "Monkey" };
            string[] wizardCompo = new string[] { "Wizard" };


            this.monkeyArmy        = new Army();
            monkeyArmy.Composition = monkeyCompo;
            monkeyArmy.Name        = "Monkey Army";
            monkeyArmy.Size        = size;

            this.wizardArmy        = new Army();
            wizardArmy.Composition = wizardCompo;
            wizardArmy.Name        = "Wizard Army";
            wizardArmy.Size        = size;

            TroopFactory factory = MockTroopFactory.Create();

            ArmyComposer composer = new ArmyComposer(factory);

            monkeyArmy.Troops = composer.Compose(monkeyArmy);
            wizardArmy.Troops = composer.Compose(wizardArmy);
        }
Exemple #2
0
        /// <summary>
        /// Get a Trooptype from a JSON
        /// </summary>
        /// <param name="contents"></param>
        /// <returns></returns>
        public Army ReadJson(string contents)
        {
            Army army = new Army();
            Dictionary <string, string> dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(contents);

            army.Name        = dict["Name"];
            army.Size        = Int32.Parse(dict["Size"]);
            army.Composition = dict["Composition"].Split(',');
            army.Troops      = composer.Compose(army);
            return(army);
        }
Exemple #3
0
        public void CommanderSetup()
        {
            int size = 7;

            string[] composition = new string[] { "Monkey", "Balloon", "Wizard" };

            army             = new Army();
            army.Composition = composition;
            army.Name        = "Test Army";
            army.Size        = size;

            TroopFactory factory = MockTroopFactory.Create();

            ArmyComposer composer = new ArmyComposer(factory);

            army.Troops = composer.Compose(army);
        }
Exemple #4
0
        public void ComposeTest()
        {
            int size = 7;

            string[] composition = new string[] { "Monkey", "Balloon", "Wizard" };

            Army army = new Army();

            army.Composition = composition;
            army.Name        = "Test Army";
            army.Size        = size;
            string[] expected = new string[] { "Monkey", "Balloon", "Wizard", "Monkey", "Balloon", "Wizard", "Monkey" };

            TroopFactory factory = MockTroopFactory.Create();

            ArmyComposer composer = new ArmyComposer(factory);
            List <Troop> troops   = composer.Compose(army);

            List <string> troopNames = troops.Select(x => x.Info.Name).ToList();

            Assert.AreEqual(expected, troopNames.ToArray());
        }