Exemplo n.º 1
0
        private static void TestPrivateVariableInBase()
        {
            var c = new Inheriter();

            Assert(43, c.GetFromPrivateInBase());

            c.SetToPrivateInBase(5);

            Assert(5, c.GetFromPrivateInBase());
        }
Exemplo n.º 2
0
        public static void TestMethods()
        {
            var obj = new Inheriter();

            Output = "";
            obj.M1();
            Assert("InheriterM1,BaseM1,", Output);

            Output = "";
            obj.M2();
            Assert("InheriterM1,BaseM1,", Output);
        }
Exemplo n.º 3
0
            public void Run <T2, T3>(T2 arg) where T2 : Tests <T3> where T3 : ImplBeta, new()
            {
                // Expect call to ImplAlpha.M().
                Interface int_alpha = new ImplAlpha();

                int_alpha.M();

                // Expect call to ImplBeta.M().
                Interface int_beta = new ImplBeta();

                int_beta.M();

                // Expect call to ImplAlpha.M().
                ImplAlpha alpha_alpha = new ImplAlpha();

                alpha_alpha.M();

                // Expect call to ImplBeta.M().
                Interface int_both = new ImplAlpha();

                int_both = new ImplBeta();
                int_both.M();

                // Expect call to ImplBeta.M().
                Interface int_beta_inheriter = new Inheriter();

                int_beta_inheriter.M();

                // Expect call to UnqualifiedM().
                UnqualifiedM();

                // Expect call to SecondLevelImpl.M().
                Interface int_secondlevelimpl = new SecondLevelImpl();

                int_secondlevelimpl.M();

                // Expect call to OnlyStaticClass.M().
                OnlyStaticClass.M();

                // Expect no detected calls as correct implementation cannot be determined (could be ImplAlpha or SecondLevelImpl).
                AlphaFactory().M();

                // Expect call to ImplBeta.M().
                BetaFactory().M();

                // Expect no detected calls as correct implementation cannot be determined.
                InterfaceFactory().M();

                // Expect call to ImplAlpha.M()
                base.M();

                // Expect call to Tests.M()
                this.M();

                // Expect call to Tests.M()
                M();

                // Expect call to ImplAlpha.M2()
                M2();

                // Expect call to ImplAlpha.M3()
                M3();

                // Expect call to ImplAlpha.M().
                typeof(ImplAlpha).InvokeMember("M", System.Reflection.BindingFlags.Public, null, alpha_alpha, new object[0]);

                var methodInfo = typeof(ImplAlpha).GetMethod("M");

                // Expect call to ImplAlpha.M().
                var args = new object[] { 42 };

                methodInfo.Invoke(alpha_alpha, args);

                // Expect call to ImplAlpha.M().
                methodInfo.Invoke(alpha_alpha, System.Reflection.BindingFlags.InvokeMethod, null, new object[0], System.Globalization.CultureInfo.CurrentCulture);

                // Expect call to UnqualifiedM().
                typeof(MainClass).InvokeMember("UnqualifiedM", System.Reflection.BindingFlags.Public, null, null, new object[0]);

                // Expect call to UnqualifiedM().
                var methodInfo2 = new MainClass().GetType().GetMethod("UnqualifiedM");

                // Expect call to UnqualifiedM().
                methodInfo2.Invoke(null, new object[0]);

                // Expect call to UnqualifiedM.M().
                methodInfo2.Invoke(null, System.Reflection.BindingFlags.InvokeMethod, null, new object[0], System.Globalization.CultureInfo.CurrentCulture);

                // Expect call to MainClass.MethodWithOut
                args = new object[] { 42, null };
                typeof(MainClass).InvokeMember("MethodWithOut", System.Reflection.BindingFlags.Public, null, null, args);

                // Expect call to MainClass.MethodWithOut2
                typeof(MainClass).InvokeMember("MethodWithOut2", System.Reflection.BindingFlags.Public, null, null, args);

                // Expect call to Tests.M()
                arg.M();

                // Expect call to ImplBeta.M()
                new T1().M();
            }
Exemplo n.º 4
0
 private static void GetConstValueFromBase()
 {
     Assert(50, Inheriter.GetConstValue());
 }
Exemplo n.º 5
0
 private static void TestPrivateVariableInBaseCstor()
 {
     var c = new Inheriter(50);
 }