Skip to content

Commit 1266207

Browse files
committed
Add test for ExecuteUpdate SetProperty ordering (#1975)
1 parent 14c2cd5 commit 1266207

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

test/EFCore.MySql.FunctionalTests/BulkUpdates/NorthwindBulkUpdatesMySqlTest.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Linq;
22
using System.Threading.Tasks;
3+
using Microsoft.EntityFrameworkCore;
34
using Microsoft.EntityFrameworkCore.BulkUpdates;
45
using Microsoft.EntityFrameworkCore.TestModels.Northwind;
56
using Microsoft.EntityFrameworkCore.TestUtilities;
@@ -1475,6 +1476,28 @@ public override async Task Update_with_two_inner_joins(bool async)
14751476
""");
14761477
}
14771478

1479+
[ConditionalTheory]
1480+
[MemberData(nameof(IsAsyncData))]
1481+
public virtual Task Update_Where_set_ordering_is_preserved(bool async)
1482+
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
1483+
Fixture.CreateContext, Fixture.UseTransaction,
1484+
async context =>
1485+
{
1486+
var updated = await context.Set<Customer>().ExecuteUpdateAsync(
1487+
setters => setters
1488+
.SetProperty(c => c.ContactName, "X")
1489+
.SetProperty(c => c.ContactTitle, c => c.ContactName + "Y"));
1490+
Assert.True(updated > 0);
1491+
Assert.Equal(updated, await context.Set<Customer>().CountAsync(c => c.ContactTitle == "XY"));
1492+
1493+
updated = await context.Set<Customer>().ExecuteUpdateAsync(
1494+
setters => setters
1495+
.SetProperty(c => c.City, "Y")
1496+
.SetProperty(c => c.ContactName, c => c.City + "X"));
1497+
Assert.True(updated > 0);
1498+
Assert.Equal(updated, await context.Set<Customer>().CountAsync(c => c.ContactName == "YX"));
1499+
});
1500+
14781501
private void AssertSql(params string[] expected)
14791502
=> Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
14801503

0 commit comments

Comments
 (0)