Skip to content

Commit d2735b6

Browse files
committed
NH-3260 - Add more tests.
1 parent e5ac6c8 commit d2735b6

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/GenericMethodShouldBeProxied.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,38 @@ public void CanProxySelfCastingMethodWithGenericInterfaceBaseConstaint4()
184184
c.AsInterfaceBase4<MyGenericClass<int>>().Should().Not.Be.Null();
185185
}
186186

187+
[Test]
188+
public void CanProxySelfCastingMethodWithGenericConstaint5()
189+
{
190+
var factory = new ProxyFactory();
191+
var c = (MyGenericClass<int>)factory.CreateProxy(typeof(MyGenericClass<int>), new PassThroughInterceptor(new MyGenericClass<int>()), null);
192+
c.As5<MyGenericClass<int>>().Should().Not.Be.Null();
193+
}
194+
195+
[Test]
196+
public void CanProxySelfCastingMethodWithGenericConstaintBase5()
197+
{
198+
var factory = new ProxyFactory();
199+
var c = (MyGenericClass<int>)factory.CreateProxy(typeof(MyGenericClass<int>), new PassThroughInterceptor(new MyGenericClass<int>()), null);
200+
c.AsBase5<MyGenericClass<int>>().Should().Not.Be.Null();
201+
}
202+
203+
[Test]
204+
public void CanProxySelfCastingMethodWithGenericInterfaceConstaint5()
205+
{
206+
var factory = new ProxyFactory();
207+
var c = (MyGenericClass<int>)factory.CreateProxy(typeof(MyGenericClass<int>), new PassThroughInterceptor(new MyGenericClass<int>()), null);
208+
c.AsInterface5<MyGenericClass<int>>().Should().Not.Be.Null();
209+
}
210+
211+
[Test]
212+
public void CanProxySelfCastingMethodWithGenericInterfaceBaseConstaint5()
213+
{
214+
var factory = new ProxyFactory();
215+
var c = (MyGenericClass<int>)factory.CreateProxy(typeof(MyGenericClass<int>), new PassThroughInterceptor(new MyGenericClass<int>()), null);
216+
c.AsInterfaceBase5<MyGenericClass<int>>().Should().Not.Be.Null();
217+
}
218+
187219
[Test]
188220
public void GenericTypeConstraint()
189221
{

src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/MyGenericClass.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,25 @@ public virtual TRequestedType AsInterfaceBase<TRequestedType>() where TRequested
6161
{
6262
return new TRequestedType();
6363
}
64+
65+
public override TRequestedType As5<TRequestedType>()
66+
{
67+
return base.As5<TRequestedType>();
68+
}
69+
70+
public override TRequestedType AsBase5<TRequestedType>()
71+
{
72+
return base.AsBase5<TRequestedType>();
73+
}
74+
75+
public override TRequestedType AsInterface5<TRequestedType>()
76+
{
77+
return base.AsInterface5<TRequestedType>();
78+
}
79+
80+
public override TRequestedType AsInterfaceBase5<TRequestedType>()
81+
{
82+
return base.AsInterfaceBase5<TRequestedType>();
83+
}
6484
}
6585
}

src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/MyGenericClassBase.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public virtual TRequestedType As4<TRequestedType>() where TRequestedType : MyGen
77
return this as TRequestedType;
88
}
99

10-
public virtual TRequestedType AsBase4<TRequestedType>() where TRequestedType : MyGenericClassBase<TId, int>
10+
public virtual TRequestedType AsBase4<TRequestedType>() where TRequestedType : MyGenericClassBase<TId, T2>
1111
{
1212
return this as TRequestedType;
1313
}
@@ -17,7 +17,27 @@ public virtual TRequestedType AsInterface4<TRequestedType>() where TRequestedTyp
1717
return this as TRequestedType;
1818
}
1919

20-
public virtual TRequestedType AsInterfaceBase4<TRequestedType>() where TRequestedType : class, IMyGenericInterface<TId>
20+
public virtual TRequestedType AsInterfaceBase4<TRequestedType>() where TRequestedType : class, IMyGenericInterfaceBase<TId>
21+
{
22+
return this as TRequestedType;
23+
}
24+
25+
public virtual TRequestedType As5<TRequestedType>() where TRequestedType : MyGenericClass<TId>
26+
{
27+
return this as TRequestedType;
28+
}
29+
30+
public virtual TRequestedType AsBase5<TRequestedType>() where TRequestedType : MyGenericClassBase<TId, T2>
31+
{
32+
return this as TRequestedType;
33+
}
34+
35+
public virtual TRequestedType AsInterface5<TRequestedType>() where TRequestedType : class, IMyGenericInterface<TId>
36+
{
37+
return this as TRequestedType;
38+
}
39+
40+
public virtual TRequestedType AsInterfaceBase5<TRequestedType>() where TRequestedType : class, IMyGenericInterfaceBase<TId>
2141
{
2242
return this as TRequestedType;
2343
}

0 commit comments

Comments
 (0)