public IActionResult Attack(string mass, string opponentEgo) { string result = ""; int massInt = 0; int opponentEgoInt = 0; //S bool massParseSuccess = int.TryParse(mass, out massInt); bool egoParseSuccess = int.TryParse(opponentEgo, out opponentEgoInt); if (massParseSuccess && egoParseSuccess) { int attackDamage = StatCalculator.Attack(massInt, opponentEgoInt); //Ha haaaaaa nice pat result = $"You did {attackDamage} damage. ALL ROIGHT"; } else if (massParseSuccess && !egoParseSuccess) { result = "Ego was not in correct format"; } else if (!massParseSuccess && egoParseSuccess) { result = "Mass was not in correct format"; } else { result = "Both mass and ego were not in correct format"; } return(Content(result)); }
public void AttackTest(int mass, int opponentEgo, int expected) { int actual = StatCalculator.Attack(mass, opponentEgo); Assert.Equal(expected, actual); }