Ejemplo n.º 1
0
        public void Test()
        {
            Entity e = (Entity)TypeAccessor.CreateInstance(typeof(Entity));

            Test2.IInterface1 t2a = (Test2.IInterface1)e;
            t2a.DoAction();
            // because of boxing  :(
            Assert.AreEqual(null /*"Test2.IAction1.DoAction"*/, e.Str);

            Test1.IInterface1 t1a = (Test1.IInterface1)e;
            t1a.DoAction();
            Assert.AreEqual("Test1.IAction1.DoAction", e.Str);

            IInterface2 a2 = (IInterface2)e;

            a2.DoAction();
            Assert.AreEqual(123, e.Int);
            Assert.AreEqual(MyDateTime.TestDate1, e.Date);

            a2.DoAction(456, null);
            Assert.AreEqual(456, e.Int);
            Assert.AreEqual(MyDateTime.TestDate2, e.Date);
            Assert.AreEqual(2, e.CallCounter);

            ISetInfo si = (ISetInfo)e;

            si.SetInfo(1, null, 2);
            Assert.AreEqual("Str", e.Str);
        }