Skip to content

Added test for bug in linq FetchLazyProperties() #3329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<Person>(1));
CollectionAssert.AreEqual(new byte[] { 0 }, person.Image);

person.Image = new byte[] { 1, 2, 3 };

var allPersons = await (s.Query<Person>().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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,25 @@ public void TestLinqFetchAllProperties()
AssertFetchAllProperties(person);
}

[Test]
public void TestLinqFetchAllProperties_WhenLazyPropertyChanged()
{
Person person;
using (var s = OpenSession())
{
person = s.Get<Person>(1);
CollectionAssert.AreEqual(new byte[] { 0 }, person.Image);

person.Image = new byte[] { 1, 2, 3 };

var allPersons = s.Query<Person>().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);
Expand Down