Beispiel #1
0
        static void Main()
        {
            {
                TestLogger.Log("Testing static initialization...");
                TestLogger.Log(si.ToString());
                TestLogger.Log(sstr == null ? "null" : sstr);
                TestLogger.Log(((int)se).ToString());
                TestLogger.Log(sc == null ? "null" : sc.ToString());
                TestLogger.Log(ss.ToString());
            }

            {
                TestLogger.Log("Testing struct initialization...");
                var s = new Struct();
                TestLogger.Log(s.ToString());
            }

            {
                TestLogger.Log("Testing struct constructor...");
                var s = new Struct(7.3, 12.11);
                TestLogger.Log(s.ToString());
            }

            {
                TestLogger.Log("Testing class initialization...");
                var c = new Class();
                TestLogger.Log(c.ToString());
            }

            {
                TestLogger.Log("Testing class constructor...");
                var c = new Class(7, "test");
                TestLogger.Log(c.ToString());
            }

            {
                TestLogger.Log("Testing derived initialization...");
                var c = new DerivedClass();
                TestLogger.Log(c.ToString());
            }

            {
                TestLogger.Log("Testing derived constructor...");
                var c = new DerivedClass(7, "test", 12);
                TestLogger.Log(c.ToString());
            }

            {
                TestLogger.Log("Testing generic initialization over int...");
                var c = new GenericClass <int>();
                TestLogger.Log(c.ToString());
            }

            {
                TestLogger.Log("Testing generic constructor over int...");
                var c = new GenericClass <int>(7);
                TestLogger.Log(c.ToString());
            }

            {
                TestLogger.Log("Testing generic initialization over string...");
                var c = new GenericClass <string>();
                TestLogger.Log(c.ToString());
            }

            {
                TestLogger.Log("Testing generic constructor over string...");
                var c = new GenericClass <string>("test");
                TestLogger.Log(c.ToString());
            }

            {
                TestLogger.Log("Testing construction of generic parameter with int...");
                var c = new GenericConstructorTest <int>();
                TestLogger.Log(c.ToString());
                TestLogger.Log(c.GenericBox().ToString());
            }

            {
                TestLogger.Log("Testing construction of generic parameter with class...");
                var c = new GenericConstructorTest <Class>();
                TestLogger.Log(c.ToString());
                TestLogger.Log(c.GenericBox().ToString());
            }
        }