Files
sbox-public/engine/Tests/Sandbox.Test.Unit/Scene/SystemsConfig.cs
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

31 lines
768 B
C#

namespace SceneTests;
[TestClass]
public class SystemsConfigTest
{
[TestMethod]
public void GetPropertyValue_UsesDefaultValueAttributeWhenUnset()
{
var typeLibrary = new Sandbox.Internal.TypeLibrary();
typeLibrary.AddAssembly( typeof( DefaultValueSystem ).Assembly, false );
var systemType = typeLibrary.GetType<DefaultValueSystem>();
var property = systemType.GetProperty( nameof( DefaultValueSystem.MyInt ) );
var config = new Sandbox.SystemsConfig();
Assert.AreEqual( 123, config.GetPropertyValue( systemType, property ) );
}
}
[Expose]
public sealed class DefaultValueSystem : GameObjectSystem
{
public DefaultValueSystem( Sandbox.Scene scene ) : base( scene )
{
}
[Property, DefaultValue( 123 )]
public int MyInt { get; set; } = 123;
}