mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 08:18:20 -04:00
* 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
51 lines
942 B
C#
51 lines
942 B
C#
using Sandbox.Internal;
|
|
|
|
namespace ReflectionTests;
|
|
|
|
[TestClass]
|
|
public class EnumDescriptionTest
|
|
{
|
|
private EnumDescription GetExampleEnumDescription()
|
|
{
|
|
var tl = new TypeLibrary();
|
|
tl.AddAssembly( GetType().Assembly, true );
|
|
|
|
return tl.GetEnumDescription( typeof( ExampleEnum ) );
|
|
}
|
|
|
|
[TestMethod]
|
|
public void GetEnumDescription()
|
|
{
|
|
var enumDesc = GetExampleEnumDescription();
|
|
|
|
Assert.AreEqual( 4, enumDesc.Count() );
|
|
}
|
|
|
|
[TestMethod]
|
|
public void GetEntryByObjectValue()
|
|
{
|
|
var enumDesc = GetExampleEnumDescription();
|
|
var enumEntry = enumDesc.GetEntry( ExampleEnum.C );
|
|
|
|
Assert.AreEqual( nameof( ExampleEnum.C ), enumEntry.Name );
|
|
}
|
|
|
|
[TestMethod]
|
|
public void GetEntryByIntegerValue()
|
|
{
|
|
var enumDesc = GetExampleEnumDescription();
|
|
var enumEntry = enumDesc.GetEntry( 2 );
|
|
|
|
Assert.AreEqual( nameof( ExampleEnum.C ), enumEntry.Name );
|
|
}
|
|
}
|
|
|
|
[Expose]
|
|
public enum ExampleEnum
|
|
{
|
|
A = 0,
|
|
B = 1,
|
|
C = 2,
|
|
D = 3
|
|
}
|