using XGame.Framework.Assertions;
using System.Diagnostics;

namespace XGame.Framework
{
    public static partial class Assert
    {
        [Conditional(MacroDefine.XGAME_ASSERT), Conditional(MacroDefine.UNITY_EDITOR)]
        public static void IsTrue(bool condition)
        {
            if (!condition)
                IsTrue(condition, null);
        }

        [Conditional(MacroDefine.XGAME_ASSERT), Conditional(MacroDefine.UNITY_EDITOR)]
        public static void IsTrue(bool condition, string format, params object[] agrs)
        {
            if (!condition)
                Fail(AssertionMessageUtil.BooleanFailureMessage(true), format, agrs);
        }

        [Conditional(MacroDefine.XGAME_ASSERT), Conditional(MacroDefine.UNITY_EDITOR)]
        public static void IsTrue<T>(bool condition, T e) where T : System.Exception, new()
        {
            if (!condition)
                Fail(AssertionMessageUtil.BooleanFailureMessage(true), e);
        }

        [Conditional(MacroDefine.XGAME_ASSERT), Conditional(MacroDefine.UNITY_EDITOR)]
        public static void IsFalse(bool condition)
        {
            if (condition)
                IsFalse(condition, null);
        }

        [Conditional(MacroDefine.XGAME_ASSERT), Conditional(MacroDefine.UNITY_EDITOR)]
        public static void IsFalse(bool condition, string format, params object[] agrs)
        {
            if (condition)
                Fail(AssertionMessageUtil.BooleanFailureMessage(false), format, agrs);
        }

        [Conditional(MacroDefine.XGAME_ASSERT), Conditional(MacroDefine.UNITY_EDITOR)]
        public static void IsFalse<T>(bool condition, T e) where T : System.Exception, new()
        {
            if (condition)
                Fail(AssertionMessageUtil.BooleanFailureMessage(false), e);
        }
    }
}
