Fixed test issue - PEVerify is now called with a quoted assembly path (to allow for...
[castle.git] / Tools / Castle.DynamicProxy2 / Castle.DynamicProxy.Tests / ProxyGenerationOptionsTestCase.cs
blobe50c3679e96b15427c166623cf8aa7e9860b309d
1 namespace Castle.DynamicProxy.Tests
3 using System;
4 using NUnit.Framework;
6 [TestFixture]
7 public class ProxyGenerationOptionsTestCase
9 ProxyGenerationOptions _options1;
10 ProxyGenerationOptions _options2;
12 [SetUp]
13 public void Init()
15 _options1 = new ProxyGenerationOptions();
16 _options2 = new ProxyGenerationOptions();
19 [Test]
20 public void Equals_EmptyOptions ()
22 Assert.AreEqual (_options1, _options2);
25 [Test]
26 public void Equals_EqualNonEmptyOptions ()
28 _options1 = new ProxyGenerationOptions ();
29 _options2 = new ProxyGenerationOptions ();
31 _options1.BaseTypeForInterfaceProxy = typeof (IConvertible);
32 _options2.BaseTypeForInterfaceProxy = typeof (IConvertible);
34 object mixin = new object ();
35 _options1.AddMixinInstance (mixin);
36 _options2.AddMixinInstance (mixin);
38 IProxyGenerationHook hook = new AllMethodsHook ();
39 _options1.Hook = hook;
40 _options2.Hook = hook;
42 IInterceptorSelector selector = new Castle.DynamicProxy.Tests.SerializableClassTestCase.SerializableInterceptorSelector ();
43 _options1.Selector = selector;
44 _options2.Selector = selector;
46 _options1.UseSelector = true;
47 _options2.UseSelector = true;
49 _options1.UseSingleInterfaceProxy = true;
50 _options2.UseSingleInterfaceProxy = true;
52 Assert.AreEqual (_options1, _options2);
55 [Test]
56 public void Equals_DifferentOptions_BaseTypeForInterfaceProxy ()
58 _options1.BaseTypeForInterfaceProxy = typeof (IConvertible);
59 _options2.BaseTypeForInterfaceProxy = typeof (object);
61 Assert.AreNotEqual (_options1, _options2);
64 [Test]
65 public void Equals_DifferentOptions_AddMixinInstance ()
67 object mixin = new object ();
68 _options1.AddMixinInstance (mixin);
70 Assert.AreNotEqual (_options1, _options2);
73 [Test]
74 public void Equals_DifferentOptions_Hook ()
76 IProxyGenerationHook hook = new GenerationHookTestCase.LogHook (typeof (object), true);
77 _options1.Hook = hook;
79 Assert.AreNotEqual (_options1, _options2);
82 [Test]
83 public void Equals_DifferentOptions_Selector ()
85 IInterceptorSelector selector = new Castle.DynamicProxy.Tests.SerializableClassTestCase.SerializableInterceptorSelector ();
86 _options1.Selector = selector;
88 Assert.AreNotEqual (_options1, _options2);
91 [Test]
92 public void Equals_DifferentOptions_UseSelector ()
94 _options1.UseSelector = true;
95 _options2.UseSelector = false;
97 Assert.AreNotEqual (_options1, _options2);
100 [Test]
101 public void Equals_DifferentOptions_UseSingleInterfaceProxy ()
103 _options1.UseSingleInterfaceProxy = true;
104 _options2.UseSingleInterfaceProxy = false;
106 Assert.AreNotEqual (_options1, _options2);
109 [Test]
110 public void GetHashCode_EmptyOptions ()
112 Assert.AreEqual (_options1.GetHashCode(), _options2.GetHashCode());
115 [Test]
116 public void GetHashCode_EqualNonEmptyOptions ()
118 _options1 = new ProxyGenerationOptions ();
119 _options2 = new ProxyGenerationOptions ();
121 _options1.BaseTypeForInterfaceProxy = typeof (IConvertible);
122 _options2.BaseTypeForInterfaceProxy = typeof (IConvertible);
124 object mixin = new object ();
125 _options1.AddMixinInstance (mixin);
126 _options2.AddMixinInstance (mixin);
128 IProxyGenerationHook hook = new AllMethodsHook ();
129 _options1.Hook = hook;
130 _options2.Hook = hook;
132 IInterceptorSelector selector = new Castle.DynamicProxy.Tests.SerializableClassTestCase.SerializableInterceptorSelector ();
133 _options1.Selector = selector;
134 _options2.Selector = selector;
136 _options1.UseSelector = true;
137 _options2.UseSelector = true;
139 _options1.UseSingleInterfaceProxy = true;
140 _options2.UseSingleInterfaceProxy = true;
142 Assert.AreEqual (_options1.GetHashCode(), _options2.GetHashCode());
145 [Test]
146 public void GetHashCode_DifferentOptions_BaseTypeForInterfaceProxy ()
148 _options1.BaseTypeForInterfaceProxy = typeof (IConvertible);
149 _options2.BaseTypeForInterfaceProxy = typeof (object);
151 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());
154 [Test]
155 public void GetHashCode_DifferentOptions_AddMixinInstance ()
157 object mixin = new object ();
158 _options1.AddMixinInstance (mixin);
160 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());
163 [Test]
164 public void GetHashCode_DifferentOptions_Hook ()
166 IProxyGenerationHook hook = new GenerationHookTestCase.LogHook (typeof (object), true);
167 _options1.Hook = hook;
169 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());
172 [Test]
173 public void GetHashCode_DifferentOptions_Selector ()
175 IInterceptorSelector selector = new Castle.DynamicProxy.Tests.SerializableClassTestCase.SerializableInterceptorSelector ();
176 _options1.Selector = selector;
178 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());
181 [Test]
182 public void GetHashCode_DifferentOptions_UseSelector ()
184 _options1.UseSelector = true;
185 _options2.UseSelector = false;
187 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());
190 [Test]
191 public void GetHashCode_DifferentOptions_UseSingleInterfaceProxy ()
193 _options1.UseSingleInterfaceProxy = true;
194 _options2.UseSingleInterfaceProxy = false;
196 Assert.AreNotEqual (_options1.GetHashCode(), _options2.GetHashCode());