示例#1
0
        public static void UnitTest_RefTest()
        {
            TestCls r = null;

            TestRef(ref r);
            Console.WriteLine("Result = " + r.TestVal2);
            float a   = 1.0f;
            float b   = a / 2;
            var   str = string.Format("{0:0.000}", b);

            Console.WriteLine(str);
        }
示例#2
0
        public static void UnitTest_OutTest()
        {
            Dictionary <int, TestCls> dic = new Dictionary <int, TestCls>();

            dic[1] = new TestCls();
            TestCls abc;

            if (dic.TryGetValue(1, out abc))
            {
                Console.WriteLine(abc.TestVal2);
            }
        }
示例#3
0
        static void UnitTest_TestStackRegisterTransition(TestCls a, bool b, TestCls c, List <TestCls> d)
        {
            Console.WriteLine(b);
            Console.WriteLine(a);
            Console.WriteLine(c.TestVal2);
            Console.WriteLine(d.Count);

            if (a != null || c.TestVal2 != 2 || d.Count != 1)
            {
                throw new Exception();
            }
        }
示例#4
0
        public static void UnitTest_TestStackRegisterTransition()
        {
            TestCls a = new TestCls();

            a.TestVal2 = 2;

            TestCls c = new TestCls();

            c.TestVal2 = 3;

            List <TestCls> d = new List <TestCls>();

            d.Add(c);
            for (int i = 0; i < 3; i++)
            {
                UnitTest_TestStackRegisterTransition(null, (i & 1) == 1, a, d);
            }
        }
示例#5
0
        public static void ReflectionTest05()
        {
            var fi  = typeof(TestCls).GetField("aa");
            var fi2 = typeof(TestCls).GetField("bb");

            var a = new TestCls();

            Console.WriteLine("aa=" + fi.GetValue(a));
            Console.WriteLine("bb=" + fi2.GetValue(null));

            fi.SetValue(a, 123);
            fi2.SetValue(null, 233);
            Console.WriteLine("aa=" + fi.GetValue(a));
            Console.WriteLine("bb=" + fi2.GetValue(null));

            a.foo(110);

            var arr = fi.GetCustomAttributes(false);

            foreach (var i in arr)
            {
                Console.WriteLine(i);
            }
        }
示例#6
0
 static int TestRef(ref TestCls dest)
 {
     dest          = new TestCases.TestCls();
     dest.TestVal2 = 2;
     return(0);
 }