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

43 lines
1.2 KiB
C#

namespace EditorTests;
/// <summary>
/// A component type for <see cref="SceneEditorTest"/> to find by name in the type library.
/// Never instantiated.
/// </summary>
public class ClipboardTestComponent : Component
{
}
[TestClass]
public class SceneEditorTest
{
/// <summary>
/// Clipboard text is component json when it's a json object whose __type resolves
/// to a known component type.
/// </summary>
[TestMethod]
public void RecognisesComponentJson()
{
Assert.IsTrue( global::Editor.SceneEditor.IsComponentJson( $$"""{ "__type": "{{nameof( ClipboardTestComponent )}}" }""" ) );
}
/// <summary>
/// Anything that isn't a json object with a known component __type should be
/// rejected without throwing - the clipboard can contain absolutely anything.
/// </summary>
[TestMethod]
[DataRow( null )]
[DataRow( "" )]
[DataRow( " " )]
[DataRow( "not json at all" )]
[DataRow( "[ 1, 2, 3 ]" )]
[DataRow( "{}" )]
[DataRow( """{ "__type": 5 }""" )]
[DataRow( """{ "__type": "NotARealComponentType" }""" )]
[DataRow( """{ "sometext": "ClipboardTestComponent" }""" )]
public void RejectsEverythingElse( string text )
{
Assert.IsFalse( global::Editor.SceneEditor.IsComponentJson( text ) );
}
}