public void TestIntroductionInterceptorWithInterfaceHierarchy()
        {
            TestObject raw = new TestObject();

            Assert.IsTrue(!(raw is ISubTimeStamped));
            ProxyFactory factory = new ProxyFactory(raw);

            ISubTimeStampedIntroduction ts = MockRepository.GenerateMock <ISubTimeStampedIntroduction>();

            ts.Stub(x => x.TimeStamp).Return(EXPECTED_TIMESTAMP);

            DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);

            // we must add introduction, not an advisor
            factory.AddIntroduction(advisor);

            object          proxy = factory.GetProxy();
            ISubTimeStamped tsp   = (ISubTimeStamped)proxy;

            Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);
        }
        public void TestIntroductionInterceptorWithSuperInterface()
        {
            TestObject raw = new TestObject();

            Assert.IsTrue(!(raw is ITimeStamped));
            ProxyFactory factory = new ProxyFactory(raw);

            ISubTimeStamped ts = MockRepository.GenerateMock <ISubTimeStampedIntroduction>();

            ts.Stub(x => x.TimeStamp).Return(EXPECTED_TIMESTAMP);

            factory.AddIntroduction(0, new DefaultIntroductionAdvisor(
                                        (ISubTimeStampedIntroduction)ts,
                                        typeof(ITimeStamped))
                                    );

            ITimeStamped tsp = (ITimeStamped)factory.GetProxy();

            Assert.IsTrue(!(tsp is ISubTimeStamped));
            Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);
        }
        public void testIntroductionInterceptorWithInterfaceHierarchy()
        {
            TestObject raw = new TestObject();

            Assert.IsTrue(!(raw is ISubTimeStamped));
            ProxyFactory factory = new ProxyFactory(raw);

            IDynamicMock tsControl         = new DynamicMock(typeof(ISubTimeStampedIntroduction));
            ISubTimeStampedIntroduction ts = (ISubTimeStampedIntroduction)tsControl.Object;

            tsControl.ExpectAndReturn("TimeStamp", EXPECTED_TIMESTAMP);

            DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);

            // we must add introduction, not an advisor
            factory.AddIntroduction(advisor);

            object          proxy = factory.GetProxy();
            ISubTimeStamped tsp   = (ISubTimeStamped)proxy;

            Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);

            tsControl.Verify();
        }
        public void testIntroductionInterceptorWithSuperInterface()
        {
            TestObject raw = new TestObject();

            Assert.IsTrue(!(raw is ITimeStamped));
            ProxyFactory factory = new ProxyFactory(raw);

            IDynamicMock    tsControl = new DynamicMock(typeof(ISubTimeStampedIntroduction));
            ISubTimeStamped ts        = (ISubTimeStamped)tsControl.Object;

            tsControl.ExpectAndReturn("TimeStamp", EXPECTED_TIMESTAMP);

            factory.AddIntroduction(0, new DefaultIntroductionAdvisor(
                                        (ISubTimeStampedIntroduction)ts,
                                        typeof(ITimeStamped))
                                    );

            ITimeStamped tsp = (ITimeStamped)factory.GetProxy();

            Assert.IsTrue(!(tsp is ISubTimeStamped));
            Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);

            tsControl.Verify();
        }