Game Development Reference
In-Depth Information
{
return _enlarged;
}
}
It will now pass the test. Build the project, run NUnit again, and a green circle
will appear next to the project. The next test is for eating a mushroom. Here's
the test.
namespace PlayerTest
{
[TestFixture]
public class TestPlayer
{
[Test]
public void BasicTest()
{
Assert.That(true);
}
[Test]
public void StartsLifeSmall()
{
Player player ¼ new Player();
Assert.False(player.IsEnlarged());
}
[Test]
public void MushroomEnlargesPlayer()
{
Player player ¼ new Player();
player.Eat("mushroom");
Assert.True(player.IsEnlarged());
}
}
}
This new test has a pleasing symmetry with the previous test. As tests are built up,
they form living documentation for the project. Someone new to the code can
read all the tests associated with a certain function and get a very good idea about
what it's supposed to do.
Search WWH ::




Custom Search