-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
SqlAzureBatchingTest.cs
48 lines (42 loc) · 1.6 KB
/
SqlAzureBatchingTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.EntityFrameworkCore.SqlAzure.Model;
namespace Microsoft.EntityFrameworkCore.SqlAzure;
[SqlServerCondition(SqlServerCondition.IsSqlAzure)]
public class SqlAzureBatchingTest : IClassFixture<BatchingSqlAzureFixture>
{
public SqlAzureBatchingTest(BatchingSqlAzureFixture fixture, ITestOutputHelper output)
{
Fixture = fixture;
}
public BatchingSqlAzureFixture Fixture { get; }
[ConditionalTheory]
[InlineData(1)]
[InlineData(10)]
[InlineData(100)]
[InlineData(1000)]
public void AddWithBatchSize(int batchSize)
{
using var context = Fixture.CreateContext(batchSize);
context.Database.CreateExecutionStrategy().Execute(
context, contextScoped =>
{
using (contextScoped.Database.BeginTransaction())
{
for (var i = 0; i < batchSize; i++)
{
var uuid = Guid.NewGuid().ToString();
contextScoped.Products.Add(
new Product
{
Name = uuid,
ProductNumber = uuid.Substring(0, 25),
Weight = 1000,
SellStartDate = DateTime.Now
});
}
Assert.Equal(batchSize, contextScoped.SaveChanges());
}
});
}
}