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); }
/// <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); }
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); }
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()); }