Files
Garry Newman d95169d8fa Unit Test Cleanup (#5064)
* Move all unit tests to Engine/Tests
* Fix Margin.EdgeSubtract
* Fix Capsule.Contains
* EnvironmentVariables.Remove if it's null
* Fixed ray trace never returning startedsolid
* Fix HistoryList.Navigate on empty list
* Fix GameObject.WorldPosition accepting NaNs
* Fix flex: initial expanding to the wrong grow/shrink
* Translation.TryConvert shouldn't throw on invalid enum strings
* Skip sound file tests on machines with no audio device
2026-06-12 13:23:50 +01:00

78 lines
1.5 KiB
C#

namespace SceneTests;
/// <summary>
/// Proves a plain scene works in this tier without booting the engine: the scene
/// world, physics world and gizmo world are all created lazily, so as long as
/// nothing renders or collides, no native engine systems get touched.
/// </summary>
[TestClass]
[DoNotParallelize]
public class SceneSmokeTest : SceneTest
{
/// <summary>
/// A scene should construct, hold objects and destroy without creating any
/// native worlds.
/// </summary>
[TestMethod]
public void CreateAndDestroyScene()
{
var scene = new Scene();
Assert.IsTrue( scene.IsValid );
using ( scene.Push() )
{
var go = scene.CreateObject();
go.Name = "Test Object";
Assert.IsTrue( go.IsValid );
Assert.AreEqual( scene, go.Scene );
}
scene.Destroy();
Assert.IsFalse( scene.IsValid );
}
/// <summary>
/// The game tick should run without rendering or physics existing.
/// </summary>
[TestMethod]
public void GameTickRuns()
{
var scene = new Scene();
using var sceneScope = scene.Push();
var go = scene.CreateObject();
scene.GameTick();
scene.GameTick();
Assert.IsTrue( go.IsValid );
scene.Destroy();
}
/// <summary>
/// Destroying an object should go through the deferred-delete queue like it does
/// in a running game.
/// </summary>
[TestMethod]
public void DeferredDestroy()
{
var scene = new Scene();
using var sceneScope = scene.Push();
var go = scene.CreateObject();
go.Destroy();
Assert.IsTrue( go.IsValid );
scene.GameTick();
Assert.IsFalse( go.IsValid );
scene.Destroy();
}
}