@@ -8,12 +8,27 @@ namespace NHibernate.Test.NHSpecificTest.ProxyValidator
8
8
[ TestFixture ]
9
9
public class ShouldBeProxiableTests
10
10
{
11
- private class MyClass : IDisposable
11
+ private class MyClass : IDisposable
12
12
{
13
13
public void Dispose ( )
14
14
{
15
15
}
16
+
17
+ ~ MyClass ( )
18
+ {
19
+ }
20
+
21
+ // ReSharper disable once InconsistentNaming
22
+ // This is intentionally lower case
23
+ public virtual void finalize ( )
24
+ {
25
+ }
26
+
27
+ public virtual void Finalize ( int a )
28
+ {
29
+ }
16
30
}
31
+
17
32
private class ProtectedNoVirtualProperty
18
33
{
19
34
protected int Aprop { get ; set ; }
@@ -44,6 +59,104 @@ public void DisposeNotBeProxiable()
44
59
Assert . That ( method . ShouldBeProxiable ( ) , Is . False ) ;
45
60
}
46
61
62
+ [ Test ]
63
+ public void ObjectDestructorShouldNotBeProxiable ( )
64
+ {
65
+ var method = typeof ( object ) . GetMethod (
66
+ "Finalize" ,
67
+ BindingFlags . NonPublic | BindingFlags . Instance ) ;
68
+
69
+ Assert . That ( method . ShouldBeProxiable ( ) , Is . False ) ;
70
+ }
71
+
72
+ [ Test ]
73
+ public void ObjectDestructorIsNotProxiable ( )
74
+ {
75
+ var method = typeof ( object ) . GetMethod (
76
+ "Finalize" ,
77
+ BindingFlags . NonPublic | BindingFlags . Instance ) ;
78
+
79
+ Assert . That ( method . IsProxiable ( ) , Is . False ) ;
80
+ }
81
+
82
+ [ Test ]
83
+ public void MyClassDestructorShouldNotBeProxiable ( )
84
+ {
85
+ var method = typeof ( MyClass ) . GetMethod (
86
+ "Finalize" ,
87
+ BindingFlags . NonPublic | BindingFlags . Instance ,
88
+ null ,
89
+ System . Type . EmptyTypes ,
90
+ null ) ;
91
+
92
+ Assert . That ( method . ShouldBeProxiable ( ) , Is . False ) ;
93
+ }
94
+
95
+ [ Test ]
96
+ public void MyClassDestructorIsNotProxiable ( )
97
+ {
98
+ var method = typeof ( MyClass ) . GetMethod (
99
+ "Finalize" ,
100
+ BindingFlags . NonPublic | BindingFlags . Instance ,
101
+ null ,
102
+ System . Type . EmptyTypes ,
103
+ null ) ;
104
+
105
+ Assert . That ( method . IsProxiable ( ) , Is . False ) ;
106
+ }
107
+
108
+ [ Test ]
109
+ public void MyClassLowerCaseFinalizeShouldBeProxiable ( )
110
+ {
111
+ var method = typeof ( MyClass ) . GetMethod (
112
+ "finalize" ,
113
+ BindingFlags . Public | BindingFlags . Instance ,
114
+ null ,
115
+ System . Type . EmptyTypes ,
116
+ null ) ;
117
+
118
+ Assert . That ( method . ShouldBeProxiable ( ) , Is . True ) ;
119
+ }
120
+
121
+ [ Test ]
122
+ public void MyClassLowerCaseFinalizeIsProxiable ( )
123
+ {
124
+ var method = typeof ( MyClass ) . GetMethod (
125
+ "finalize" ,
126
+ BindingFlags . Public | BindingFlags . Instance ,
127
+ null ,
128
+ System . Type . EmptyTypes ,
129
+ null ) ;
130
+
131
+ Assert . That ( method . IsProxiable ( ) , Is . True ) ;
132
+ }
133
+
134
+ [ Test ]
135
+ public void MyClassFinalizeWithParametersShouldBeProxiable ( )
136
+ {
137
+ var method = typeof ( MyClass ) . GetMethod (
138
+ "Finalize" ,
139
+ BindingFlags . Public | BindingFlags . Instance ,
140
+ null ,
141
+ new [ ] { typeof ( int ) } ,
142
+ null ) ;
143
+
144
+ Assert . That ( method . ShouldBeProxiable ( ) , Is . True ) ;
145
+ }
146
+
147
+ [ Test ]
148
+ public void MyClassFinalizeWithParametersIsProxiable ( )
149
+ {
150
+ var method = typeof ( MyClass ) . GetMethod (
151
+ "Finalize" ,
152
+ BindingFlags . Public | BindingFlags . Instance ,
153
+ null ,
154
+ new [ ] { typeof ( int ) } ,
155
+ null ) ;
156
+
157
+ Assert . That ( method . IsProxiable ( ) , Is . True ) ;
158
+ }
159
+
47
160
[ Test ]
48
161
public void WhenProtectedNoVirtualPropertyThenShouldntBeProxiable ( )
49
162
{
0 commit comments