Simple impl to MockRailsEngineContext.Url
[castle.git] / Tools / DynamicProxy / Castle.DynamicProxy.Tests / DotNet2Tests.cs
blobd40f53be03547a9592a8f32cfebb1d6f5c3184ba
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 #if DOTNET2
16 namespace Castle.DynamicProxy.Test
18 using System;
19 using System.Collections.Generic;
20 using System.Text;
21 using NUnit.Framework;
22 using System.Runtime.CompilerServices;
24 [TestFixture]
25 public class DotNet2Tests
27 [Test]
28 public void ProxyGenericClass()
30 ProxyGenerator pg = new ProxyGenerator();
31 GenericClass<int> x = (GenericClass<int>)pg.CreateClassProxy(typeof(GenericClass<int>),
32 new StandardInterceptor());
34 Assert.IsFalse(x.SomeMethod());
36 GenericClass<string> y = (GenericClass<string>)pg.CreateClassProxy(typeof(GenericClass<string>),
37 new StandardInterceptor());
39 Assert.IsFalse(y.SomeMethod());
42 [Test]
43 public void ProxyGenericInterface()
45 ProxyGenerator pg = new ProxyGenerator();
46 IList<int> x = (IList<int>)pg.CreateProxy(typeof(IList<int>),
47 new StandardInterceptor(), new List<int>());
49 Assert.AreEqual(0, x.Count);
51 IList<string> y = (IList<string>)pg.CreateProxy(typeof(IList<string>),
52 new StandardInterceptor(), new List<string>());
54 Assert.AreEqual(0, y.Count);
57 [Test]
58 public void ProxyGenericInterfaceWithTwoGenericParameters()
60 IDictionary<int, float> ints = new Dictionary<int, float>();
61 ProxyGenerator pg = new ProxyGenerator();
62 IDictionary<int, float> x = (IDictionary<int, float>)pg.CreateProxy(typeof(IDictionary<int, float>),
63 new StandardInterceptor(), ints);
65 Assert.AreEqual(0, x.Count);
68 [Test]
69 public void ProxyInternalClass()
71 ProxyGenerator pg = new ProxyGenerator();
72 LogInvocationInterceptor logger = new LogInvocationInterceptor();
73 InternalClass x = (InternalClass)pg.CreateClassProxy(typeof(InternalClass),
74 logger);
75 x.Name = "ayende";
76 Assert.AreEqual("ayende", x.Name);
77 Assert.AreEqual("set_Name", logger.Invocations[0]);
78 Assert.AreEqual("get_Name", logger.Invocations[1]);
82 public class GenericClass<T>
84 public virtual bool SomeMethod() { return false; }
87 internal class InternalClass
89 String _name;
91 internal virtual String Name
93 get { return _name; }
94 set { _name = value; }
100 #endif