Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Tools / Castle.DynamicProxy2 / Castle.DynamicProxy.Tests / ProxyGenerationOptionsTestCase.cs
blob5635e63b3d13759feb0fd6eaea77b70b032279f9
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.Tests
17 using System;
18 using NUnit.Framework;
20 [TestFixture]
21 public class ProxyGenerationOptionsTestCase
23 ProxyGenerationOptions _options1;
24 ProxyGenerationOptions _options2;
26 [SetUp]
27 public void Init()
29 _options1 = new ProxyGenerationOptions();
30 _options2 = new ProxyGenerationOptions();
33 [Test]
34 public void Equals_EmptyOptions ()
36 Assert.AreEqual (_options1, _options2);
39 [Test]
40 public void Equals_EqualNonEmptyOptions ()
42 _options1 = new ProxyGenerationOptions ();
43 _options2 = new ProxyGenerationOptions ();
45 _options1.BaseTypeForInterfaceProxy = typeof (IConvertible);
46 _options2.BaseTypeForInterfaceProxy = typeof (IConvertible);
48 object mixin = new object ();
49 _options1.AddMixinInstance (mixin);
50 _options2.AddMixinInstance (mixin);
52 IProxyGenerationHook hook = new AllMethodsHook ();
53 _options1.Hook = hook;
54 _options2.Hook = hook;
56 IInterceptorSelector selector = new Castle.DynamicProxy.Tests.SerializableClassTestCase.SerializableInterceptorSelector ();
57 _options1.Selector = selector;
58 _options2.Selector = selector;
60 _options1.UseSelector = true;
61 _options2.UseSelector = true;
63 _options1.UseSingleInterfaceProxy = true;
64 _options2.UseSingleInterfaceProxy = true;
66 Assert.AreEqual (_options1, _options2);
69 [Test]
70 public void Equals_DifferentOptions_BaseTypeForInterfaceProxy ()
72 _options1.BaseTypeForInterfaceProxy = typeof (IConvertible);
73 _options2.BaseTypeForInterfaceProxy = typeof (object);
75 Assert.AreNotEqual (_options1, _options2);
78 [Test]
79 public void Equals_DifferentOptions_AddMixinInstance ()
81 object mixin = new object ();
82 _options1.AddMixinInstance (mixin);
84 Assert.AreNotEqual (_options1, _options2);
87 [Test]
88 public void Equals_DifferentOptions_Hook ()
90 IProxyGenerationHook hook = new GenerationHookTestCase.LogHook (typeof (object), true);
91 _options1.Hook = hook;
93 Assert.AreNotEqual (_options1, _options2);
96 [Test]
97 public void Equals_DifferentOptions_Selector ()
99 IInterceptorSelector selector = new Castle.DynamicProxy.Tests.SerializableClassTestCase.SerializableInterceptorSelector ();
100 _options1.Selector = selector;
102 Assert.AreNotEqual (_options1, _options2);
105 [Test]
106 public void Equals_DifferentOptions_UseSelector ()
108 _options1.UseSelector = true;
109 _options2.UseSelector = false;
111 Assert.AreNotEqual (_options1, _options2);
114 [Test]
115 public void Equals_DifferentOptions_UseSingleInterfaceProxy ()
117 _options1.UseSingleInterfaceProxy = true;
118 _options2.UseSingleInterfaceProxy = false;
120 Assert.AreNotEqual (_options1, _options2);
123 [Test]
124 public void GetHashCode_EmptyOptions ()
126 Assert.AreEqual (_options1.GetHashCode(), _options2.GetHashCode());
129 [Test]
130 public void GetHashCode_EqualNonEmptyOptions ()
132 _options1 = new ProxyGenerationOptions ();
133 _options2 = new ProxyGenerationOptions ();
135 _options1.BaseTypeForInterfaceProxy = typeof (IConvertible);
136 _options2.BaseTypeForInterfaceProxy = typeof (IConvertible);
138 object mixin = new object ();
139 _options1.AddMixinInstance (mixin);
140 _options2.AddMixinInstance (mixin);
142 IProxyGenerationHook hook = new AllMethodsHook ();
143 _options1.Hook = hook;
144 _options2.Hook = hook;
146 IInterceptorSelector selector = new Castle.DynamicProxy.Tests.SerializableClassTestCase.SerializableInterceptorSelector ();
147 _options1.Selector = selector;
148 _options2.Selector = selector;
150 _options1.UseSelector = true;
151 _options2.UseSelector = true;
153 _options1.UseSingleInterfaceProxy = true;
154 _options2.UseSingleInterfaceProxy = true;
156 Assert.AreEqual (_options1.GetHashCode(), _options2.GetHashCode());
159 [Test]
160 public void GetHashCode_DifferentOptions_BaseTypeForInterfaceProxy ()
162 _options1.BaseTypeForInterfaceProxy = typeof (IConvertible);
163 _options2.BaseTypeForInterfaceProxy = typeof (object);
165 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());
168 [Test]
169 public void GetHashCode_DifferentOptions_AddMixinInstance ()
171 object mixin = new object ();
172 _options1.AddMixinInstance (mixin);
174 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());
177 [Test]
178 public void GetHashCode_DifferentOptions_Hook ()
180 IProxyGenerationHook hook = new GenerationHookTestCase.LogHook (typeof (object), true);
181 _options1.Hook = hook;
183 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());
186 [Test]
187 public void GetHashCode_DifferentOptions_Selector ()
189 IInterceptorSelector selector = new Castle.DynamicProxy.Tests.SerializableClassTestCase.SerializableInterceptorSelector ();
190 _options1.Selector = selector;
192 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());
195 [Test]
196 public void GetHashCode_DifferentOptions_UseSelector ()
198 _options1.UseSelector = true;
199 _options2.UseSelector = false;
201 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());
204 [Test]
205 public void GetHashCode_DifferentOptions_UseSingleInterfaceProxy ()
207 _options1.UseSingleInterfaceProxy = true;
208 _options2.UseSingleInterfaceProxy = false;
210 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());