The Wizards Engine : Working with Unit tests

This information is only correct for writing tests for code in the Gameplay project.

Running tests

Tests can be run by pressing F5 while the engine is active. The selected test will then run automatically on engine start-up. Press R to restart the test.

Creating tests

Tests for the gameplay projects are currently located with the code they are testing, there is no separate test project yet. Here is an example of a basic engine test class.

[TestFixture] // Indicates this is a unit test
[EngineTest] // Indicates this should run inside the engine
public class ExampleTest
{
    // Retrieve access to the engine
    private TWEngine engine = EngineFactory.CreateEngine();
    [SetUp]
    public void Setup()
    {
        // Test setup code can be added here. It is run every time a test is started.
    }
        
    [Test]
    public void TestGenerateBottomIslandHeightmap()
    {
        engine.AddSimulator(new BasicSimulator(delegate
        {
            // Add custom gameloop logic here
        }));
        engine.AddSimulator(new PhysicalSimulator()); // Enables the use of Physical objects
        engine.AddSimulator(new WorldRenderingSimulator()); // Enables the renderer
    }
    [Test]
    public void TestGenerateIsland()
    {
        // Unit tests that do not use the engine directly are allowed too!
        Assert.AreEqual(5,5);
    }
}