@@ -62,6 +62,19 @@ public MapScenario(ISessionFactory factory)
62
62
{ "Child1" , new Child ( ) } ,
63
63
{ "NullChild" , null } ,
64
64
} ;
65
+
66
+ var child1 = new AnotherChild { Name = "AnotherChild1" } ;
67
+ var child2 = new AnotherChild { Name = "AnotherChild2" } ;
68
+
69
+ s . Save ( child1 ) ;
70
+ s . Save ( child2 ) ;
71
+
72
+ entity . OneToManyNamedChildren = new Dictionary < string , AnotherChild >
73
+ {
74
+ { "AnotherChild1" , child1 } ,
75
+ { "AnotherChild2" , child2 }
76
+ } ;
77
+
65
78
s . Save ( entity ) ;
66
79
t . Commit ( ) ;
67
80
}
@@ -143,8 +156,11 @@ public void Map_Item()
143
156
var entity = s . CreateQuery ( "from Base" ) . UniqueResult < Base > ( ) ;
144
157
// null collection members don't seem to work, at least for lazy="extra" collections
145
158
entity . NamedChildren . Count . Should ( ) . Be . EqualTo ( 2 ) ;
159
+ entity . OneToManyNamedChildren . Count . Should ( ) . Be . EqualTo ( 2 ) ;
146
160
NHibernateUtil . IsInitialized ( entity . NamedChildren ) . Should ( ) . Be . False ( ) ;
147
161
Executing . This ( ( ) => { Child ignored = entity . NamedChildren [ "InvalidKey" ] ; } ) . Should ( ) . Throw < KeyNotFoundException > ( ) ;
162
+ Executing . This ( ( ) => { AnotherChild ignored = entity . OneToManyNamedChildren [ "InvalidKey" ] ; } ) . Should ( ) . Throw < KeyNotFoundException > ( ) ;
163
+ NHibernateUtil . IsInitialized ( entity . NamedChildren ) . Should ( ) . Be . False ( ) ;
148
164
}
149
165
}
150
166
}
@@ -161,12 +177,16 @@ public void Map_TryGetValue_Invalid()
161
177
{
162
178
// accessing an invalid key should fail or throw an exception, depending on method
163
179
var entity = s . CreateQuery ( "from Base" ) . UniqueResult < Base > ( ) ;
164
- // null collection members don't seem to work, at least for lazy="extra" collections
180
+ // null collection members don't seem to work, at least for lazy="extra" collectionsb
165
181
entity . NamedChildren . Count . Should ( ) . Be . EqualTo ( 2 ) ;
166
182
NHibernateUtil . IsInitialized ( entity . NamedChildren ) . Should ( ) . Be . False ( ) ;
167
183
Child child ;
168
184
entity . NamedChildren . TryGetValue ( "InvalidKey" , out child ) . Should ( ) . Be . False ( ) ;
169
185
child . Should ( ) . Be . Null ( ) ;
186
+ AnotherChild anotherChild ;
187
+ entity . OneToManyNamedChildren . TryGetValue ( "InvalidKey" , out anotherChild ) . Should ( ) . Be . False ( ) ;
188
+ child . Should ( ) . Be . Null ( ) ;
189
+ NHibernateUtil . IsInitialized ( entity . NamedChildren ) . Should ( ) . Be . False ( ) ;
170
190
}
171
191
}
172
192
}
0 commit comments