Game Development Reference
In-Depth Information
return false;
}
}
Two more tests have been added—each requiring a new player function.
class Player
{
public int Health { get; set; }
public bool IsDead()
{
return false;
}
public void OnHit()
{
}
public Player()
{
Health ¼ 10;
}
}
The general method of unit testing is to write the test, update the code, run the
test, and if it fails, modify the code until it passes the test. If the new tests are run
on the updated code, they will both fail. Let's fix that.
class Player
{
public int Health { get; set; }
public bool IsDead()
{
return Health == 0;
}
public void OnHit()
{
Health--;
}
public Player()
{
Health ¼ 10;
}
}
Search WWH ::




Custom Search