formatC() public static method

public static formatC ( string str, string color ) : string
str string
color string
return string
示例#1
0
    public static void debug(string name, bool didPass, string failExplaination = null)
    {
        float  num   = LeanTest.printOutLength(name);
        int    num2  = 40 - (int)(num * 1.05f);
        string text  = string.Empty.PadRight(num2, "_".get_Chars(0));
        string text2 = string.Concat(new string[]
        {
            LeanTest.formatB(name),
            " ",
            text,
            " [ ",
            didPass ? LeanTest.formatC("pass", "green") : LeanTest.formatC("fail", "red"),
            " ]"
        });

        if (!didPass && failExplaination != null)
        {
            text2 = text2 + " - " + failExplaination;
        }
        Debug.Log(text2);
        if (didPass)
        {
            LeanTest.passes++;
        }
        LeanTest.tests++;
        if (LeanTest.tests == LeanTest.expected)
        {
            Debug.Log(string.Concat(new string[]
            {
                LeanTest.formatB("Final Report:"),
                " _____________________ PASSED: ",
                LeanTest.formatBC(string.Empty + LeanTest.passes, "green"),
                " FAILED: ",
                LeanTest.formatBC(string.Empty + (LeanTest.tests - LeanTest.passes), "red"),
                " "
            }));
        }
        else if (LeanTest.tests > LeanTest.expected)
        {
            Debug.Log(LeanTest.formatB("Too many tests for a final report!") + " set LeanTest.expected = " + LeanTest.tests);
        }
    }
示例#2
0
    public static void expect(bool didPass, string definition, string failExplaination = null)
    {
        float  single = LeanTest.printOutLength(definition);
        int    num    = 40 - (int)(single * 1.05f);
        string str    = "".PadRight(num, "_"[0]);

        string[] strArrays = new string[] { LeanTest.formatB(definition), " ", str, " [ ", null, null };
        strArrays[4] = (didPass ? LeanTest.formatC("pass", "green") : LeanTest.formatC("fail", "red"));
        strArrays[5] = " ]";
        string str1 = string.Concat(strArrays);

        if (!didPass && failExplaination != null)
        {
            str1 = string.Concat(str1, " - ", failExplaination);
        }
        Debug.Log(str1);
        if (didPass)
        {
            LeanTest.passes++;
        }
        LeanTest.tests++;
        if (LeanTest.tests == LeanTest.expected && !LeanTest.testsFinished)
        {
            LeanTest.overview();
        }
        else if (LeanTest.tests > LeanTest.expected)
        {
            Debug.Log(string.Concat(LeanTest.formatB("Too many tests for a final report!"), " set LeanTest.expected = ", LeanTest.tests));
        }
        if (!LeanTest.timeoutStarted)
        {
            LeanTest.timeoutStarted = true;
            GameObject gameObject = new GameObject()
            {
                name = "~LeanTest"
            };
            (gameObject.AddComponent(typeof(LeanTester)) as LeanTester).timeout = LeanTest.timeout;
            gameObject.hideFlags = HideFlags.HideAndDontSave;
        }
    }
示例#3
0
 public static string formatBC(string str, string color)
 {
     return(LeanTest.formatC(LeanTest.formatB(str), color));
 }