File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed
NHibernate.Test/GhostProperty Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 1
1
using System . Collections ;
2
2
using NHibernate . ByteCode . Castle ;
3
3
using NHibernate . Cfg ;
4
+ using NHibernate . Tuple . Entity ;
4
5
using NUnit . Framework ;
5
6
6
7
namespace NHibernate . Test . GhostProperty
7
8
{
8
9
[ TestFixture ]
9
10
public class GhostPropertyFixture : TestCase
10
11
{
12
+ private string log ;
13
+
11
14
protected override string MappingsAssembly
12
15
{
13
16
get { return "NHibernate.Test" ; }
@@ -55,6 +58,21 @@ protected override void OnTearDown()
55
58
}
56
59
}
57
60
61
+ protected override void BuildSessionFactory ( )
62
+ {
63
+ using ( var logSpy = new LogSpy ( typeof ( EntityMetamodel ) ) )
64
+ {
65
+ base . BuildSessionFactory ( ) ;
66
+ log = logSpy . GetWholeLog ( ) ;
67
+ }
68
+ }
69
+
70
+ [ Test ]
71
+ public void ShouldGenerateErrorForNonAutoPropGhostProp ( )
72
+ {
73
+ Assert . IsTrue ( log . Contains ( "Lazy or ghost property NHibernate.Test.GhostProperty.Order.Payment is not an auto property, which may result in uninitialized property access" ) ) ;
74
+ }
75
+
58
76
[ Test ]
59
77
public void CanGetActualValueFromLazyManyToOne ( )
60
78
{
Original file line number Diff line number Diff line change 3
3
public class Order
4
4
{
5
5
public virtual int Id { get ; set ; }
6
- public virtual Payment Payment { get ; set ; }
6
+ private Payment payment ;
7
+
8
+ public virtual Payment Payment
9
+ {
10
+ get { return payment ; }
11
+ set { payment = value ; }
12
+ }
7
13
}
8
14
9
15
public abstract class Payment
Original file line number Diff line number Diff line change @@ -303,7 +303,8 @@ private static void VerifyCanInterceptPropertiesForLazyOrGhostProperties(Persist
303
303
{
304
304
foreach ( var prop in persistentClass . PropertyClosureIterator )
305
305
{
306
- if ( prop . IsLazy == false && prop . UnwrapProxy )
306
+ if ( prop . IsLazy == false &&
307
+ prop . UnwrapProxy == false )
307
308
continue ;
308
309
309
310
var getter = prop . GetGetter ( persistentClass . MappedClass ) ;
You can’t perform that action at this time.
0 commit comments