Skip to content

Commit e8db770

Browse files
committed
.
1 parent 6113c26 commit e8db770

5 files changed

Lines changed: 49 additions & 3 deletions

File tree

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public async Task Queryable()
190190
await Verify(queryable);
191191
}
192192
```
193-
<sup><a href='/src/Tests/Tests.cs#L86-L95' title='File snippet `queryable` was extracted from'>snippet source</a> | <a href='#snippet-queryable' title='Navigate to start of snippet `queryable`'>anchor</a></sup>
193+
<sup><a href='/src/Tests/Tests.cs#L113-L122' title='File snippet `queryable` was extracted from'>snippet source</a> | <a href='#snippet-queryable' title='Navigate to start of snippet `queryable`'>anchor</a></sup>
194194
<!-- endsnippet -->
195195

196196
Will result in the following verified file:

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<PropertyGroup>
44
<NoWarn>CS1591;CS0649;CS8632</NoWarn>
5-
<Version>0.1.0</Version>
5+
<Version>0.1.1</Version>
66
<PackageTags>EntityFramework, Verify</PackageTags>
77
<Description>Extends Verify (https://github.com/SimonCropp/Verify) to allow verification of EntityFramework bits.</Description>
88
</PropertyGroup>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
Modified: {
3+
Company: {
4+
Id: 0,
5+
Content: {
6+
Original: 'companyBefore',
7+
Current: 'companyAfter'
8+
}
9+
},
10+
Employee: {
11+
Id: 0,
12+
Content: {
13+
Original: 'employeeBefore',
14+
Current: 'employeeAfter'
15+
}
16+
}
17+
}
18+
}

src/Tests/Tests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,33 @@ public async Task Modified()
6262
}
6363
#endregion
6464
[Fact]
65+
public async Task WithNavigationProp()
66+
{
67+
var options = DbContextOptions();
68+
69+
await using (var context = new SampleDbContext(options))
70+
{
71+
var company = new Company
72+
{
73+
Content = "companyBefore"
74+
};
75+
context.Add(company);
76+
context.Add(new Employee
77+
{
78+
Content = "employeeBefore",
79+
Company = company
80+
});
81+
context.SaveChanges();
82+
}
83+
84+
await using (var context = new SampleDbContext(options))
85+
{
86+
context.Companies.Single().Content = "companyAfter";
87+
context.Employees.Single().Content = "employeeAfter";
88+
await Verify(context);
89+
}
90+
}
91+
[Fact]
6592
public async Task SomePropsModified()
6693
{
6794
var options = DbContextOptions();

src/Verify.EntityFramework/Extensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ public static class Extensions
77
public static IEnumerable<PropertyEntry> ChangedProperties(this EntityEntry entry)
88
{
99
return entry.Properties
10-
.Where(x => x.IsModified);
10+
.Where(x => x.IsModified &&
11+
x.OriginalValue != x.CurrentValue);
1112
}
1213

1314
public static IEnumerable<(string name, object value)> FindPrimaryKeyValues(this EntityEntry entry)

0 commit comments

Comments
 (0)