Adding ignored bug test for DYNPROXY-51
[castle.git] / Tools / Castle.DynamicProxy2 / Castle.DynamicProxy.Tests / BugsReportedTestCase.cs
blob0db5fce76e10048c58fe9f49de4b311178fd4885
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 using System;
16 using Castle.Core.Interceptor;
17 using Castle.DynamicProxy.Tests.BugsReported;
18 using NUnit.Framework;
20 namespace Castle.DynamicProxy.Tests
22 [TestFixture]
23 public class BugsReportedTestCase
25 [Test]
26 public void InterfaceInheritance()
28 ProxyGenerator generator = new ProxyGenerator();
30 ICameraService proxy = (ICameraService)
31 generator.CreateInterfaceProxyWithTarget(typeof(ICameraService),
32 new CameraService(),
33 new StandardInterceptor());
35 Assert.IsNotNull(proxy);
37 proxy.Add("", "");
38 proxy.Record(null);
41 [Test]
42 public void ProxyInterfaceWithSetterOnly()
44 ProxyGenerator generator = new ProxyGenerator();
46 IHaveOnlySetter proxy = (IHaveOnlySetter)
47 generator.CreateInterfaceProxyWithTarget(typeof(IHaveOnlySetter),
48 new HaveOnlySetter(),
49 new SkipCallingMethodInterceptor());
51 Assert.IsNotNull(proxy);
53 proxy.Foo = "bar";
56 [Test]
57 [ExpectedException(typeof(NotImplementedException),
58 "This is a DynamicProxy2 error: the interceptor attempted to 'Proceed' for a method without a target, for example, an interface method or an abstract method"
60 public void CallingProceedOnAbstractMethodShouldThrowException()
62 ProxyGenerator generator = new ProxyGenerator();
64 AbstractClass proxy = (AbstractClass)
65 generator.CreateClassProxy(typeof(AbstractClass), ProxyGenerationOptions.Default, new StandardInterceptor());
67 Assert.IsNotNull(proxy);
69 proxy.Foo();
72 [Test]
73 public void ProxyTypeThatInheritFromGenericType()
75 ProxyGenerator generator = new ProxyGenerator();
77 IUserRepository proxy = (IUserRepository)
78 generator.CreateInterfaceProxyWithoutTarget(typeof(IUserRepository),
79 new SkipCallingMethodInterceptor());
81 Assert.IsNotNull(proxy);
84 [Test]
85 [Ignore("Need to discuss why we are calling interf.GetGenericArguments() in class emitter")]
86 public void DYNPROXY_51_GenericMarkerInterface()
88 ProxyGenerator gen = new ProxyGenerator();
89 WithMixin p = (WithMixin)gen.CreateClassProxy(typeof(WithMixin), new Type[] { typeof(Marker<int>) }, new IInterceptor[0]);
90 p.Method();
95 public interface IRepository<TEntity, TKey>
97 TEntity GetById(TKey key);
100 public class User
104 public interface IUserRepository : IRepository<User, string>
108 public abstract class AbstractClass
110 public abstract string Foo();
113 public class SkipCallingMethodInterceptor : IInterceptor
115 public void Intercept(IInvocation invocation)
120 public interface IHaveOnlySetter
122 string Foo { set; }
125 public class HaveOnlySetter : IHaveOnlySetter
127 public string Foo
129 set { throw new Exception("The method or operation is not implemented."); }
133 public interface Marker<T>
137 public class WithMixin
139 public virtual void Method()