|
From: <fab...@us...> - 2011-05-10 18:22:03
|
Revision: 5809
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5809&view=rev
Author: fabiomaulo
Date: 2011-05-10 18:21:57 +0000 (Tue, 10 May 2011)
Log Message:
-----------
No failing test for proxy
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/
trunk/nhibernate/src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/GenericMethodShouldBeProxied.cs
Added: trunk/nhibernate/src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/GenericMethodShouldBeProxied.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/GenericMethodShouldBeProxied.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/DynamicProxyTests/GenericMethodsTests/GenericMethodShouldBeProxied.cs 2011-05-10 18:21:57 UTC (rev 5809)
@@ -0,0 +1,48 @@
+using System.Collections.Generic;
+using NHibernate.Proxy.DynamicProxy;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.DynamicProxyTests.GenericMethodsTests
+{
+ public class GenericMethodShouldBeProxied
+ {
+ public class MyClass
+ {
+ public virtual object Method<T>()
+ {
+ if(typeof(T) == typeof(int))
+ {
+ return 5;
+ }
+ if (typeof(T) == typeof(string))
+ {
+ return "blha";
+ }
+ return default(T);
+ }
+
+ public virtual TRequestedType As<TRequestedType>() where TRequestedType : MyClass
+ {
+ return this as TRequestedType;
+ }
+ }
+
+ [Test]
+ public void ProxyOfAGenericMethod()
+ {
+ var factory = new ProxyFactory();
+ var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null);
+ c.Method<int>().Should().Be(5);
+ c.Method<string>().Should().Be("blha");
+ }
+
+ [Test]
+ public void ProxyOfSelfCastingMethod()
+ {
+ var factory = new ProxyFactory();
+ var c = (MyClass)factory.CreateProxy(typeof(MyClass), new PassThroughInterceptor(new MyClass()), null);
+ c.As<MyClass>().Should().Not.Be.Null();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-05-10 17:39:47 UTC (rev 5808)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-05-10 18:21:57 UTC (rev 5809)
@@ -219,6 +219,7 @@
<Compile Include="DriverTest\Sql2008DateTime2Test.cs" />
<Compile Include="DriverTest\SqlClientDriverFixture.cs" />
<Compile Include="DriverTest\SqlServerCeDriverFixture.cs" />
+ <Compile Include="DynamicProxyTests\GenericMethodsTests\GenericMethodShouldBeProxied.cs" />
<Compile Include="DynamicProxyTests\InterfaceProxySerializationTests\IMyProxy.cs" />
<Compile Include="DynamicProxyTests\InterfaceProxySerializationTests\MyProxyImpl.cs" />
<Compile Include="DynamicProxyTests\InterfaceProxySerializationTests\ProxyFixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|