Skip to content

Commit 1919480

Browse files
Fix a null ref exception in a flaky test.
1 parent b8af99f commit 1919480

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/NHibernate.Test/Async/NHSpecificTest/NH3634/FixtureByCode.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public async Task QueryOverComponentWithANullPropertyAsync()
129129
.Where(p => p.Connection == componentToCompare)
130130
.SingleOrDefaultAsync<Person>());
131131

132+
Assert.That(sally, Is.Not.Null);
132133
Assert.That(sally.Name, Is.EqualTo("Sally"));
133134
Assert.That(sally.Connection.PortName, Is.Null);
134135
}
@@ -164,6 +165,7 @@ public async Task QueryAgainstComponentWithANullPropertyUsingCriteriaAsync()
164165
.Add(Restrictions.Eq("Connection", componentToCompare))
165166
.UniqueResultAsync<Person>());
166167

168+
Assert.That(sally, Is.Not.Null);
167169
Assert.That(sally.Name, Is.EqualTo("Sally"));
168170
Assert.That(sally.Connection.PortName, Is.Null);
169171
}
@@ -187,6 +189,7 @@ public async Task CachedQueryMissesWithDifferentNotNullComponentAsync()
187189
.SetCacheable(true)
188190
.UniqueResultAsync<CachedPerson>());
189191

192+
Assert.That(cached, Is.Not.Null);
190193
Assert.That(cached.Name, Is.EqualTo("CachedNull"));
191194
Assert.That(cached.Connection.PortName, Is.Null);
192195

@@ -234,6 +237,7 @@ public async Task CachedQueryMissesWithDifferentNullComponentAsync()
234237
.SetCacheable(true)
235238
.UniqueResultAsync<CachedPerson>());
236239

240+
Assert.That(cached, Is.Not.Null);
237241
Assert.That(cached.Name, Is.EqualTo("CachedNotNull"));
238242
Assert.That(cached.Connection.PortName, Is.Not.Null);
239243

@@ -281,6 +285,7 @@ public async Task CachedQueryAgainstComponentWithANullPropertyUsingCriteriaAsync
281285
.SetCacheable(true)
282286
.UniqueResultAsync<CachedPerson>());
283287

288+
Assert.That(cached, Is.Not.Null);
284289
Assert.That(cached.Name, Is.EqualTo("CachedNull"));
285290
Assert.That(cached.Connection.PortName, Is.Null);
286291

@@ -303,6 +308,7 @@ public async Task CachedQueryAgainstComponentWithANullPropertyUsingCriteriaAsync
303308
.SetCacheable(true)
304309
.UniqueResultAsync<CachedPerson>());
305310

311+
Assert.That(cached, Is.Not.Null);
306312
Assert.That(cached.Name, Is.EqualTo("CachedNull"));
307313
Assert.That(cached.Connection.PortName, Is.Null);
308314

@@ -332,6 +338,7 @@ public async Task QueryOverANullComponentPropertyAsync()
332338
.And(p => p.Connection.ConnectionType == "http")
333339
.SingleOrDefaultAsync<Person>());
334340

341+
Assert.That(sally, Is.Not.Null);
335342
Assert.That(sally.Name, Is.EqualTo("Sally"));
336343
Assert.That(sally.Connection.PortName, Is.Null);
337344
}
@@ -349,6 +356,7 @@ public async Task QueryAgainstANullComponentPropertyUsingCriteriaApiAsync()
349356
.Add(Restrictions.Eq("Connection.ConnectionType", "http"))
350357
.UniqueResultAsync<Person>());
351358

359+
Assert.That(sally, Is.Not.Null);
352360
Assert.That(sally.Name, Is.EqualTo("Sally"));
353361
Assert.That(sally.Connection.PortName, Is.Null);
354362
}

src/NHibernate.Test/NHSpecificTest/NH3634/FixtureByCode.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public void QueryOverComponentWithANullProperty()
118118
.Where(p => p.Connection == componentToCompare)
119119
.SingleOrDefault<Person>();
120120

121+
Assert.That(sally, Is.Not.Null);
121122
Assert.That(sally.Name, Is.EqualTo("Sally"));
122123
Assert.That(sally.Connection.PortName, Is.Null);
123124
}
@@ -153,6 +154,7 @@ public void QueryAgainstComponentWithANullPropertyUsingCriteria()
153154
.Add(Restrictions.Eq("Connection", componentToCompare))
154155
.UniqueResult<Person>();
155156

157+
Assert.That(sally, Is.Not.Null);
156158
Assert.That(sally.Name, Is.EqualTo("Sally"));
157159
Assert.That(sally.Connection.PortName, Is.Null);
158160
}
@@ -176,6 +178,7 @@ public void CachedQueryMissesWithDifferentNotNullComponent()
176178
.SetCacheable(true)
177179
.UniqueResult<CachedPerson>();
178180

181+
Assert.That(cached, Is.Not.Null);
179182
Assert.That(cached.Name, Is.EqualTo("CachedNull"));
180183
Assert.That(cached.Connection.PortName, Is.Null);
181184

@@ -223,6 +226,7 @@ public void CachedQueryMissesWithDifferentNullComponent()
223226
.SetCacheable(true)
224227
.UniqueResult<CachedPerson>();
225228

229+
Assert.That(cached, Is.Not.Null);
226230
Assert.That(cached.Name, Is.EqualTo("CachedNotNull"));
227231
Assert.That(cached.Connection.PortName, Is.Not.Null);
228232

@@ -270,6 +274,7 @@ public void CachedQueryAgainstComponentWithANullPropertyUsingCriteria()
270274
.SetCacheable(true)
271275
.UniqueResult<CachedPerson>();
272276

277+
Assert.That(cached, Is.Not.Null);
273278
Assert.That(cached.Name, Is.EqualTo("CachedNull"));
274279
Assert.That(cached.Connection.PortName, Is.Null);
275280

@@ -292,6 +297,7 @@ public void CachedQueryAgainstComponentWithANullPropertyUsingCriteria()
292297
.SetCacheable(true)
293298
.UniqueResult<CachedPerson>();
294299

300+
Assert.That(cached, Is.Not.Null);
295301
Assert.That(cached.Name, Is.EqualTo("CachedNull"));
296302
Assert.That(cached.Connection.PortName, Is.Null);
297303

@@ -321,6 +327,7 @@ public void QueryOverANullComponentProperty()
321327
.And(p => p.Connection.ConnectionType == "http")
322328
.SingleOrDefault<Person>();
323329

330+
Assert.That(sally, Is.Not.Null);
324331
Assert.That(sally.Name, Is.EqualTo("Sally"));
325332
Assert.That(sally.Connection.PortName, Is.Null);
326333
}
@@ -338,6 +345,7 @@ public void QueryAgainstANullComponentPropertyUsingCriteriaApi()
338345
.Add(Restrictions.Eq("Connection.ConnectionType", "http"))
339346
.UniqueResult<Person>();
340347

348+
Assert.That(sally, Is.Not.Null);
341349
Assert.That(sally.Name, Is.EqualTo("Sally"));
342350
Assert.That(sally.Connection.PortName, Is.Null);
343351
}

0 commit comments

Comments
 (0)