Exemple #1
0
        public void VirtualCallFromCtor()
        {
            StandardInterceptor interceptor         = new StandardInterceptor();
            ClassCallingVirtualMethodFromCtor proxy = generator.CreateClassProxy <ClassCallingVirtualMethodFromCtor>(interceptor);

            Assert.AreEqual(7, proxy.Result);
        }
Exemple #2
0
        public void MixinWithSameInterface_InterfaceWithTarget_AdditionalInterfaces_Derived()
        {
            ProxyGenerationOptions options = new ProxyGenerationOptions();
            SimpleMixin            mixin1  = new SimpleMixin();

            options.AddMixinInstance(mixin1);

            StandardInterceptor interceptor = new StandardInterceptor();
            var proxy = generator.CreateInterfaceProxyWithTarget(typeof(IService), new Type[] { typeof(IDerivedSimpleMixin) }, new ServiceImpl(), options, interceptor);

            Assert.AreEqual(1, (proxy as ISimpleMixin).DoSomething());
        }
Exemple #3
0
        public void TwoMixinsWithSameInterface()
        {
            ProxyGenerationOptions             options = new ProxyGenerationOptions();
            SimpleMixin                        mixin1  = new SimpleMixin();
            OtherMixinImplementingISimpleMixin mixin2  = new OtherMixinImplementingISimpleMixin();

            options.AddMixinInstance(mixin1);
            options.AddMixinInstance(mixin2);

            StandardInterceptor interceptor = new StandardInterceptor();

            generator.CreateClassProxy(typeof(SimpleClass), options, interceptor);
        }
        public void TwoMixinsWithSameInterface()
        {
            ProxyGenerationOptions             options = new ProxyGenerationOptions();
            SimpleMixin                        mixin1  = new SimpleMixin();
            OtherMixinImplementingISimpleMixin mixin2  = new OtherMixinImplementingISimpleMixin();

            options.AddMixinInstance(mixin1);
            options.AddMixinInstance(mixin2);

            StandardInterceptor interceptor = new StandardInterceptor();

            Assert.Throws <InvalidMixinConfigurationException>(() =>
                                                               generator.CreateClassProxy(typeof(SimpleClass), options, interceptor)
                                                               );
        }
Exemple #5
0
		public void MixinWithSameInterface_InterfaceWithTarget_AdditionalInterfaces_Derived()
		{
			ProxyGenerationOptions options = new ProxyGenerationOptions();
			SimpleMixin mixin1 = new SimpleMixin();
			options.AddMixinInstance(mixin1);

			StandardInterceptor interceptor = new StandardInterceptor();
			var proxy = generator.CreateInterfaceProxyWithTarget(typeof(IService), new Type[] { typeof(IDerivedSimpleMixin) }, new ServiceImpl(), options, interceptor);
			Assert.AreEqual(1, (proxy as ISimpleMixin).DoSomething());
		}
Exemple #6
0
		public void TwoMixinsWithSameInterface()
		{
			ProxyGenerationOptions options = new ProxyGenerationOptions();
			SimpleMixin mixin1 = new SimpleMixin();
			OtherMixinImplementingISimpleMixin mixin2 = new OtherMixinImplementingISimpleMixin();
			options.AddMixinInstance(mixin1);
			options.AddMixinInstance(mixin2);

			StandardInterceptor interceptor = new StandardInterceptor();

			Assert.Throws<InvalidMixinConfigurationException>(() =>
				generator.CreateClassProxy(typeof(SimpleClass), options, interceptor)
			);
		}
		public void VirtualCallFromCtor()
		{
			StandardInterceptor interceptor = new StandardInterceptor();
			ClassCallingVirtualMethodFromCtor proxy = generator.CreateClassProxy<ClassCallingVirtualMethodFromCtor>(interceptor);
			Assert.AreEqual(7, proxy.Result);
		}
Exemple #8
0
		public void TwoMixinsWithSameInterface()
		{
			ProxyGenerationOptions options = new ProxyGenerationOptions();
			SimpleMixin mixin1 = new SimpleMixin();
			OtherMixinImplementingISimpleMixin mixin2 = new OtherMixinImplementingISimpleMixin();
			options.AddMixinInstance(mixin1);
			options.AddMixinInstance(mixin2);

			StandardInterceptor interceptor = new StandardInterceptor();
			generator.CreateClassProxy(typeof(SimpleClass), options, interceptor);
		}