Assert() public static method

public static Assert ( bool cond, string msg ) : void
cond bool
msg string
return void
コード例 #1
0
ファイル: Tests.cs プロジェクト: 2cwldys/fodev-tools
        static void Iterating()
        {
            var  arr  = new IntArray(new [] { 0, 1, 2, 3 });
            bool iter = true;
            int  i    = 0;
            int  c    = 0;

            foreach (var e in arr)
            {
                c++;
                if (e != i++)
                {
                    iter = false;
                }
            }
            Tests.Assert(iter, "Iterating over value array");
            Tests.Assert(c == arr.Length, "Iteration count");
        }
コード例 #2
0
ファイル: Tests.cs プロジェクト: 2cwldys/fodev-tools
        public static void Tests_IllegalCalls()
        {
            var module_ = ScriptEngine.GetModule("test", asEGMFlags.asGM_ALWAYS_CREATE);

            module_.AddScriptSection("test", @"
int foo()
{
    return 1;
}
class TestClass
{
    int field;
    int method()
    {
        return field;
    }
}
TestClass Obj();
");
            module_.Build();
            var module = module_ as dynamic;

            try
            {
                module.Foobar();
                Tests.Assert(false, "Calling nonexisting function");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Calling nonexisting function");
            }
            try
            {
                var x = module.Ohmy;
                Tests.Assert(false, "Getting nonexisting global variable");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Getting nonexisting global variable");
            }
            try
            {
                module.Woosh = 5;
                Tests.Assert(false, "Setting nonexisting global variable");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Setting nonexisting global variable");
            }
            try
            {
                module.Obj.Boo();
                Tests.Assert(false, "Calling nonexisting method");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Calling nonexisting method");
            }
            try
            {
                var f = module.Obj.Field;
                Tests.Assert(false, "Getting nonexisting field");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Getting nonexisting field");
            }
            try
            {
                module.Obj.BrtmBrtm = 55;
                Tests.Assert(false, "Setting nonexisting field");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Setting nonexisting field");
            }
        }
コード例 #3
0
ファイル: Tests.cs プロジェクト: 2cwldys/fodev-tools
 static void assert(bool cond, string msg)
 {
     Tests.Assert(cond, msg);
 }