mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-03 01:09:29 -04:00
31 lines
764 B
C#
31 lines
764 B
C#
namespace Scene;
|
|
|
|
[TestClass]
|
|
public class SystemsConfigTests
|
|
{
|
|
[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;
|
|
}
|