public void ProxyInternalClass()
        {
            ProxyGenerator           pg     = new ProxyGenerator();
            LogInvocationInterceptor logger = new LogInvocationInterceptor();
            InternalClass            x      = (InternalClass)pg.CreateClassProxy(typeof(InternalClass),
                                                                                 logger);

            x.Name = "ayende";
            Assert.AreEqual("ayende", x.Name);
            Assert.AreEqual("set_Name", logger.Invocations[0]);
            Assert.AreEqual("get_Name", logger.Invocations[1]);
        }
Esempio n. 2
0
		public void ProtectedMethods()
		{
			ProxyGenerator generator = new ProxyGenerator();

			LogInvocationInterceptor logger = new LogInvocationInterceptor();

			NonPublicMethodsClass proxy = (NonPublicMethodsClass) 
				generator.CreateClassProxy( typeof(NonPublicMethodsClass), logger );

			proxy.DoSomething();

			Assert.AreEqual( 2, logger.Invocations.Length );
			Assert.AreEqual( "DoSomething", logger.Invocations[0] );
			Assert.AreEqual( "DoOtherThing", logger.Invocations[1] );
		}
        public void ProtectedMethods()
        {
            ProxyGenerator generator = new ProxyGenerator();

            LogInvocationInterceptor logger = new LogInvocationInterceptor();

            NonPublicMethodsClass proxy = (NonPublicMethodsClass)
                                          generator.CreateClassProxy(typeof(NonPublicMethodsClass), logger);

            proxy.DoSomething();

            Assert.AreEqual(2, logger.Invocations.Length);
            Assert.AreEqual("DoSomething", logger.Invocations[0]);
            Assert.AreEqual("DoOtherThing", logger.Invocations[1]);
        }
Esempio n. 4
0
		public void MethodsAreInterceptedInChain()
		{
			LogInvocationInterceptor interceptor = new LogInvocationInterceptor();
			
			object proxy = _generator.CreateClassProxy( 
				typeof(ServiceClass2), interceptor);

			ServiceClass2 obj = (ServiceClass2) proxy;
			
			obj.DoSomething();
			obj.DoOtherThing();
			
			Assert.AreEqual(4, interceptor.Invocations.Length);
			Assert.AreEqual("DoOtherThing", interceptor.Invocations[0]);
			Assert.AreEqual("DoSomethingElse", interceptor.Invocations[1]);
			Assert.AreEqual("DoOtherThing", interceptor.Invocations[2]);
			Assert.AreEqual("DoSomethingElse", interceptor.Invocations[3]);
		}