diff --git a/src/NHibernate.Test/Async/FetchLazyProperties/FetchLazyPropertiesFixture.cs b/src/NHibernate.Test/Async/FetchLazyProperties/FetchLazyPropertiesFixture.cs index 2783bfead0d..5514911e104 100644 --- a/src/NHibernate.Test/Async/FetchLazyProperties/FetchLazyPropertiesFixture.cs +++ b/src/NHibernate.Test/Async/FetchLazyProperties/FetchLazyPropertiesFixture.cs @@ -276,6 +276,25 @@ public async Task TestLinqFetchAllPropertiesAsync() AssertFetchAllProperties(person); } + [Test] + public async Task TestLinqFetchAllProperties_WhenLazyPropertyChangedAsync() + { + Person person; + using (var s = OpenSession()) + { + person = await (s.GetAsync(1)); + CollectionAssert.AreEqual(new byte[] { 0 }, person.Image); + + person.Image = new byte[] { 1, 2, 3 }; + + var allPersons = await (s.Query().FetchLazyProperties().ToListAsync()); + // After execute FetchLazyProperties(), I expected to see that the person.Image would be { 1, 2, 3 }. + // Because I changed this person.Image manually, I didn't want to lose those changes. + // But test failed. Оld value returned { 0 }. + CollectionAssert.AreEqual(new byte[] { 1, 2, 3 }, person.Image); // test failed + } + } + private static void AssertFetchAllProperties(Person person) { Assert.That(person, Is.Not.Null); diff --git a/src/NHibernate.Test/FetchLazyProperties/FetchLazyPropertiesFixture.cs b/src/NHibernate.Test/FetchLazyProperties/FetchLazyPropertiesFixture.cs index 43d68dce93d..7b3b8a4e632 100644 --- a/src/NHibernate.Test/FetchLazyProperties/FetchLazyPropertiesFixture.cs +++ b/src/NHibernate.Test/FetchLazyProperties/FetchLazyPropertiesFixture.cs @@ -265,6 +265,25 @@ public void TestLinqFetchAllProperties() AssertFetchAllProperties(person); } + [Test] + public void TestLinqFetchAllProperties_WhenLazyPropertyChanged() + { + Person person; + using (var s = OpenSession()) + { + person = s.Get(1); + CollectionAssert.AreEqual(new byte[] { 0 }, person.Image); + + person.Image = new byte[] { 1, 2, 3 }; + + var allPersons = s.Query().FetchLazyProperties().ToList(); + // After execute FetchLazyProperties(), I expected to see that the person.Image would be { 1, 2, 3 }. + // Because I changed this person.Image manually, I didn't want to lose those changes. + // But test failed. Оld value returned { 0 }. + CollectionAssert.AreEqual(new byte[] { 1, 2, 3 }, person.Image); // test failed + } + } + private static void AssertFetchAllProperties(Person person) { Assert.That(person, Is.Not.Null);