Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Tools / DynamicProxy / Castle.DynamicProxy.Tests / CachedTypeTestCase.cs
blobee71c8f08acc388fc6428d191bc45b298d8d699e
1 // Copyright 2004-2008 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 namespace Castle.DynamicProxy.Test
17 using System;
19 using NUnit.Framework;
21 using Castle.DynamicProxy.Test.Classes;
23 /// <summary>
24 /// Summary description for CachedTypeTestCase.
25 /// </summary>
26 [TestFixture]
27 public class CachedTypeTestCase
29 private ProxyGenerator _generator = new ProxyGenerator();
31 [Test]
32 public void CachedClassProxies()
34 object proxy = _generator.CreateClassProxy(
35 typeof(ServiceClass), new StandardInterceptor( ) );
37 Assert.IsNotNull(proxy);
38 Assert.IsTrue( typeof(ServiceClass).IsAssignableFrom( proxy.GetType() ) );
40 proxy = _generator.CreateClassProxy(
41 typeof(ServiceClass), new StandardInterceptor( ) );
43 Assert.IsNotNull(proxy);
44 Assert.IsTrue( typeof(ServiceClass).IsAssignableFrom( proxy.GetType() ) );
47 [Test]
48 public void GenerateProxyClassSameNameDistinctNamespace()
50 object proxyA = _generator.CreateClassProxy(typeof(Classes.SimpleClass),new StandardInterceptor());
51 object proxyB = _generator.CreateClassProxy(typeof(Classes.SubNamespace.SimpleClass), new StandardInterceptor());
53 Assert.IsTrue(proxyA is Classes.SimpleClass,
54 string.Format("Proxy {0} is not a subclass of {1} ", proxyA.GetType(), typeof(Classes.SimpleClass)));
56 Assert.IsTrue(proxyB is Classes.SubNamespace.SimpleClass,
57 string.Format("Proxy {0} is not a subclass of {1}", proxyA.GetType(), typeof(Classes.SubNamespace.SimpleClass)));
60 [Test]
61 public void GenerateProxyClassSameNameButOneIsInnerClass()
63 object proxyA = _generator.CreateClassProxy(typeof(Classes.Foo), new StandardInterceptor());
64 object proxyB = _generator.CreateClassProxy(typeof(Classes.DuplicateNames.Foo), new StandardInterceptor());
66 Assert.IsTrue(proxyA is Classes.Foo,
67 string.Format("Proxy {0} is not a subclass of {1} ", proxyA.GetType(), typeof(Classes.Foo)));
69 Assert.IsTrue(proxyB is Classes.DuplicateNames.Foo,
70 string.Format("Proxy {0} is not a subclass of {1}", proxyA.GetType(), typeof(Classes.DuplicateNames.Foo)));
73 #if DOTNET2
75 [Test]
76 public void GenerateProxyOfGenericType()
79 object proxyA = _generator.CreateClassProxy(typeof(genericClass<int>), new StandardInterceptor());
80 object proxyB = _generator.CreateClassProxy(typeof(genericClass<int>), new StandardInterceptor());
82 Assert.AreEqual(proxyA.GetType(), proxyB.GetType(),"Wrong types for generic classes");
87 public class genericClass<T>
89 public T Field;
91 #endif