public void TestTroopSpeed(Formula formula) { ITroopStub troopstub = Substitute.For <ITroopStub>(); troopstub.TotalCount.Returns((ushort)1); troopstub.City.Template[0].Battle.Speed.Returns((byte)12); // fighter troopstub.City.Template[0].Upkeep.Returns((byte)1); troopstub.City.Template[1].Battle.Speed.Returns((byte)16); // Archer troopstub.City.Template[1].Upkeep.Returns((byte)1); troopstub.City.Template[2].Battle.Speed.Returns((byte)24); // Cavalry troopstub.City.Template[2].Upkeep.Returns((byte)2); troopstub.City.Template[3].Battle.Speed.Returns((byte)5); // Catapult troopstub.City.Template[3].Upkeep.Returns((byte)5); troopstub.City.Template[3].Battle.Armor.Returns(ArmorType.Machine); // 10 fighters IEnumerable <IFormation> formation = new[] { new Formation(FormationType.Normal) { { 0, 10 }, } }; troopstub.GetEnumerator().Returns(formation.GetEnumerator()); formula.GetTroopSpeed(troopstub).Should().Be(12); // 5 archers formation = new[] { new Formation(FormationType.Normal) { { 1, 5 }, } }; troopstub.GetEnumerator().Returns(formation.GetEnumerator()); formula.GetTroopSpeed(troopstub).Should().Be(16); // 10 fighters and 5 archers formation = new[] { new Formation(FormationType.Normal) { { 0, 10 }, { 1, 5 }, } }; troopstub.GetEnumerator().Returns(formation.GetEnumerator()); formula.GetTroopSpeed(troopstub).Should().Be(Math.Round((10m * 12 + 5 * 16) / 15, 1)); // 10 fighters, 5 archers, and 2 cavalries formation = new[] { new Formation(FormationType.Normal) { { 0, 10 }, { 1, 5 }, { 2, 2 }, } }; troopstub.GetEnumerator().Returns(formation.GetEnumerator()); formula.GetTroopSpeed(troopstub).Should().Be(Math.Round((10m * 12 + 5 * 16 + 4 * 24) / 19, 1)); // 10 fighters, 5 archers, 2 cavalries and 8 catapults formation = new[] { new Formation(FormationType.Normal) { { 0, 10 }, { 1, 5 }, { 2, 2 }, { 3, 8 }, } }; troopstub.GetEnumerator().Returns(formation.GetEnumerator()); formula.GetTroopSpeed(troopstub).Should().Be(5); }