public void AttackTest(TestClient testClient, string armyID, string targetID) { testClient.Attack(armyID, targetID); Client client = null; if (!ValidClientState(testClient, out client)) { Task <string> ReplyTask = testClient.GetServerMessage(); ReplyTask.Wait(); string reply = ReplyTask.Result; Assert.AreEqual("Invalid message sequence-expecting login", reply); return; } else { Task <ProtoMessage> ReplyTask = testClient.GetReply(); ReplyTask.Wait(); ProtoMessage reply = ReplyTask.Result; Army army = null; if (armyID != null) { Globals_Game.armyMasterList.TryGetValue(armyID, out army); } Army targetArmy = null; if (targetID != null) { Globals_Game.armyMasterList.TryGetValue(targetID, out targetArmy); } ProtoMessage tmp = null; if (army == null || targetArmy == null) { Assert.IsTrue(reply.ResponseType == DisplayMessages.ErrorGenericMessageInvalid || reply.ResponseType == DisplayMessages.ErrorGenericArmyUnidentified || reply.ResponseType == DisplayMessages.Error); } else if (army.CalcArmySize() == 0 || targetArmy.CalcArmySize() == 0) { Assert.AreEqual(DisplayMessages.Error, reply.ResponseType); } else if (!client.myPlayerCharacter.myArmies.Contains(army)) { Assert.AreEqual(DisplayMessages.ErrorGenericUnauthorised, reply.ResponseType); } else if (client.myPlayerCharacter.myArmies.Contains(targetArmy)) { Assert.AreEqual(DisplayMessages.ArmyAttackSelf, reply.ResponseType); } else if (!army.ChecksBeforeAttack(targetArmy, out tmp)) { Assert.AreEqual(tmp.ResponseType, reply.ResponseType); } else { Assert.IsTrue(reply.ResponseType == DisplayMessages.BattleBringSuccess || reply.ResponseType == DisplayMessages.BattleBringFail || reply.ResponseType == DisplayMessages.BattleResults); } } }