47 lines
2.5 KiB
C#
47 lines
2.5 KiB
C#
using System.Runtime.CompilerServices;
|
|
|
|
namespace Engine.Core.Debug;
|
|
|
|
public static class Assert
|
|
{
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void AssertTrue(bool value, string errorMessage)
|
|
=> System.Diagnostics.Debug.Assert(value, errorMessage);
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void AssertFalse(bool value, string errorMessage)
|
|
=> System.Diagnostics.Debug.Assert(!value, errorMessage);
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void AssertNull(object? value, string errorMessage)
|
|
=> System.Diagnostics.Debug.Assert(value is null, errorMessage);
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void AssertNotNull(object? value, string errorMessage)
|
|
=> System.Diagnostics.Debug.Assert(value is not null, errorMessage);
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void AssertInitialized(IInitializable initializable)
|
|
=> System.Diagnostics.Debug.Assert(initializable.IsInitialized, $"{initializable.GetType().Name} must be initialized");
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void AssertBehaviourControllerAssigned(IHasBehaviourController assignable)
|
|
=> System.Diagnostics.Debug.Assert(assignable.BehaviourController is not null, $"{assignable.GetType().Name} must be assigned an {nameof(IBehaviourController)}");
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void AssertEntityAssigned(IHasEntity assignable)
|
|
=> System.Diagnostics.Debug.Assert(assignable.Entity is not null, $"{assignable.GetType().Name} must be assigned an {nameof(IEntity)}");
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void AssertUniverseAssigned(IHasUniverse assignable)
|
|
=> System.Diagnostics.Debug.Assert(assignable.Universe is not null, $"{assignable.GetType().Name} must be assigned an {nameof(IUniverse)}");
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void AssertUniverseObjectAssigned(IHasUniverseObject assignable)
|
|
=> System.Diagnostics.Debug.Assert(assignable.UniverseObject is not null, $"{assignable.GetType().Name} must be assigned an {nameof(IUniverseObject)}");
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void AssertStateEnableAssigned(IHasStateEnable assignable)
|
|
=> System.Diagnostics.Debug.Assert(assignable.StateEnable is not null, $"{assignable.GetType().Name} must be assigned an {nameof(IStateEnable)}");
|
|
}
|