Skip to content

Commit 70e8380

Browse files
committed
Fixed broken tests
1 parent 91fb217 commit 70e8380

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

src/NHibernate.Test/Async/LazyGroup/LazyGroupFixture.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ public async Task TestGroupsAsync()
101101
[TestCase(false)]
102102
public async Task TestUpdateAsync(bool fetchBeforeUpdate, CancellationToken cancellationToken = default(CancellationToken))
103103
{
104+
Sfi.Statistics.Clear();
105+
104106
using (var s = OpenSession())
105107
using (var tx = s.BeginTransaction())
106108
{
@@ -115,6 +117,8 @@ public async Task TestGroupsAsync()
115117
await (tx.CommitAsync(cancellationToken));
116118
}
117119

120+
Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(1));
121+
118122
using (var s = OpenSession())
119123
using (var tx = s.BeginTransaction())
120124
{

src/NHibernate.Test/Async/LazyProperty/LazyPropertyFixture.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ protected override string[] Mappings
3636
get { return new[] { "LazyProperty.Mappings.hbm.xml" }; }
3737
}
3838

39+
protected override string CacheConcurrencyStrategy => null;
40+
3941
protected override DebugSessionFactory BuildSessionFactory()
4042
{
4143
using (var logSpy = new LogSpy(typeof(EntityMetamodel)))

src/NHibernate.Test/LazyGroup/LazyGroupFixture.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ public void TestGroups()
9090
[TestCase(false)]
9191
public void TestUpdate(bool fetchBeforeUpdate)
9292
{
93+
Sfi.Statistics.Clear();
94+
9395
using (var s = OpenSession())
9496
using (var tx = s.BeginTransaction())
9597
{
@@ -104,6 +106,8 @@ public void TestUpdate(bool fetchBeforeUpdate)
104106
tx.Commit();
105107
}
106108

109+
Assert.That(Sfi.Statistics.EntityUpdateCount, Is.EqualTo(1));
110+
107111
using (var s = OpenSession())
108112
using (var tx = s.BeginTransaction())
109113
{

src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ protected override string[] Mappings
2323
get { return new[] { "LazyProperty.Mappings.hbm.xml" }; }
2424
}
2525

26+
protected override string CacheConcurrencyStrategy => null;
27+
2628
protected override DebugSessionFactory BuildSessionFactory()
2729
{
2830
using (var logSpy = new LogSpy(typeof(EntityMetamodel)))

src/NHibernate/Persister/Entity/AbstractEntityPersister.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,11 +1460,10 @@ private object InitializeLazyPropertiesFromDatastore(
14601460
object[] snapshot = entry.LoadedState;
14611461
foreach (var fetchGroupPropertyDescriptor in fetchGroupPropertyDescriptors)
14621462
{
1463-
if (!uninitializedLazyProperties.Contains(fetchGroupPropertyDescriptor.Name))
1464-
{
1465-
// its already been initialized (e.g. by a write) so we don't want to overwrite
1466-
continue;
1467-
}
1463+
// Iterate over all fetched properties even if they are already set
1464+
// as their state may not be populated yet. InitializeLazyProperty
1465+
// method will take care of not overriding their property values and
1466+
// will only update the states, if they have one.
14681467

14691468
var selectedValue = fetchGroupPropertyDescriptor.Type.NullSafeGet(
14701469
rs,
@@ -1479,7 +1478,7 @@ private object InitializeLazyPropertiesFromDatastore(
14791478
snapshot,
14801479
fetchGroupPropertyDescriptor.LazyIndex,
14811480
selectedValue,
1482-
null
1481+
uninitializedLazyProperties
14831482
);
14841483

14851484
if (set)

0 commit comments

Comments
 (0)