1 namespace Castle
.DynamicProxy
.Tests
7 public class ProxyGenerationOptionsTestCase
9 ProxyGenerationOptions _options1
;
10 ProxyGenerationOptions _options2
;
15 _options1
= new ProxyGenerationOptions();
16 _options2
= new ProxyGenerationOptions();
20 public void Equals_EmptyOptions ()
22 Assert
.AreEqual (_options1
, _options2
);
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
);
56 public void Equals_DifferentOptions_BaseTypeForInterfaceProxy ()
58 _options1
.BaseTypeForInterfaceProxy
= typeof (IConvertible
);
59 _options2
.BaseTypeForInterfaceProxy
= typeof (object);
61 Assert
.AreNotEqual (_options1
, _options2
);
65 public void Equals_DifferentOptions_AddMixinInstance ()
67 object mixin
= new object ();
68 _options1
.AddMixinInstance (mixin
);
70 Assert
.AreNotEqual (_options1
, _options2
);
74 public void Equals_DifferentOptions_Hook ()
76 IProxyGenerationHook hook
= new GenerationHookTestCase
.LogHook (typeof (object), true);
77 _options1
.Hook
= hook
;
79 Assert
.AreNotEqual (_options1
, _options2
);
83 public void Equals_DifferentOptions_Selector ()
85 IInterceptorSelector selector
= new Castle
.DynamicProxy
.Tests
.SerializableClassTestCase
.SerializableInterceptorSelector ();
86 _options1
.Selector
= selector
;
88 Assert
.AreNotEqual (_options1
, _options2
);
92 public void Equals_DifferentOptions_UseSelector ()
94 _options1
.UseSelector
= true;
95 _options2
.UseSelector
= false;
97 Assert
.AreNotEqual (_options1
, _options2
);
101 public void Equals_DifferentOptions_UseSingleInterfaceProxy ()
103 _options1
.UseSingleInterfaceProxy
= true;
104 _options2
.UseSingleInterfaceProxy
= false;
106 Assert
.AreNotEqual (_options1
, _options2
);
110 public void GetHashCode_EmptyOptions ()
112 Assert
.AreEqual (_options1
.GetHashCode(), _options2
.GetHashCode());
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());
146 public void GetHashCode_DifferentOptions_BaseTypeForInterfaceProxy ()
148 _options1
.BaseTypeForInterfaceProxy
= typeof (IConvertible
);
149 _options2
.BaseTypeForInterfaceProxy
= typeof (object);
151 Assert
.AreNotEqual (_options1
.GetHashCode(), _options2
.GetHashCode());
155 public void GetHashCode_DifferentOptions_AddMixinInstance ()
157 object mixin
= new object ();
158 _options1
.AddMixinInstance (mixin
);
160 Assert
.AreNotEqual (_options1
.GetHashCode(), _options2
.GetHashCode());
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());
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());
182 public void GetHashCode_DifferentOptions_UseSelector ()
184 _options1
.UseSelector
= true;
185 _options2
.UseSelector
= false;
187 Assert
.AreNotEqual (_options1
.GetHashCode(), _options2
.GetHashCode());
191 public void GetHashCode_DifferentOptions_UseSingleInterfaceProxy ()
193 _options1
.UseSingleInterfaceProxy
= true;
194 _options2
.UseSingleInterfaceProxy
= false;
196 Assert
.AreNotEqual (_options1
.GetHashCode(), _options2
.GetHashCode());