Skip to content

Commit 08e6d61

Browse files
committed
Automated dotnet-format update from commit 8bfb585 on refs/heads/dev
1 parent 8bfb585 commit 08e6d61

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

test/WeihanLi.EntityFramework.Test/EFUnitOfWorkTest.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void TransactionTest()
2525
IServiceScope scope1 = null;
2626
try
2727
{
28-
_semaphore.Wait();
28+
_semaphore.Wait(TestContext.Current.CancellationToken);
2929
scope1 = Services.CreateScope();
3030
var repository = scope1.ServiceProvider.GetRequiredService<IEFRepository<TestDbContext, TestEntity>>();
3131

@@ -115,7 +115,7 @@ public async Task TransactionAsyncTest()
115115
IServiceScope scope1 = null;
116116
try
117117
{
118-
await _semaphore.WaitAsync();
118+
await _semaphore.WaitAsync(TestContext.Current.CancellationToken);
119119
scope1 = Services.CreateScope();
120120
var repository = scope1.ServiceProvider.GetRequiredService<IEFRepositoryFactory<TestDbContext>>()
121121
.GetRepository<TestEntity>();
@@ -150,7 +150,7 @@ await repository.InsertAsync(new[]
150150
CreatedAt = DateTime.UtcNow,
151151
Name = "xss3",
152152
}
153-
});
153+
}, TestContext.Current.CancellationToken);
154154

155155
using (var scope = Services.CreateScope())
156156
{
@@ -159,10 +159,10 @@ await repo.InsertAsync(new TestEntity()
159159
{
160160
CreatedAt = DateTime.UtcNow,
161161
Name = "xxxxxx"
162-
});
162+
}, TestContext.Current.CancellationToken);
163163
}
164164

165-
var beforeCount = await repository.CountAsync();
165+
var beforeCount = await repository.CountAsync(cancellationToken: TestContext.Current.CancellationToken);
166166
using var uow = repository.GetUnitOfWork();
167167
uow.DbContext.Update(new TestEntity()
168168
{
@@ -187,15 +187,15 @@ await repo.InsertAsync(new TestEntity()
187187
Name = "xyy1",
188188
});
189189

190-
var beforeCommitCount = await repository.CountAsync();
190+
var beforeCommitCount = await repository.CountAsync(cancellationToken: TestContext.Current.CancellationToken);
191191
Assert.Equal(beforeCount, beforeCommitCount);
192192

193-
await uow.CommitAsync();
193+
await uow.CommitAsync(TestContext.Current.CancellationToken);
194194

195195
var committedCount = await repository.CountAsync(cancellationToken: TestContext.Current.CancellationToken);
196196
Assert.Equal(committedCount, beforeCount + 1);
197197

198-
entity = await repository.DbContext.FindAsync<TestEntity>(3);
198+
entity = await repository.DbContext.FindAsync<TestEntity>(new object[] { 3 }, TestContext.Current.CancellationToken);
199199
Assert.Equal(new string('3', 6), entity.Name);
200200

201201
entity = await repository.DbContext.FindAsync<TestEntity>(new object[] { 4 }, cancellationToken: TestContext.Current.CancellationToken);
@@ -218,7 +218,7 @@ public void RollbackTest()
218218
{
219219
try
220220
{
221-
_semaphore.Wait();
221+
_semaphore.Wait(TestContext.Current.CancellationToken);
222222

223223
using (var scope = Services.CreateScope())
224224
{
@@ -257,7 +257,7 @@ public async Task RollbackAsyncTest()
257257
{
258258
try
259259
{
260-
await _semaphore.WaitAsync();
260+
await _semaphore.WaitAsync(TestContext.Current.CancellationToken);
261261

262262
using (var scope = Services.CreateScope())
263263
{
@@ -267,7 +267,7 @@ public async Task RollbackAsyncTest()
267267
.Add(new TestEntity() { CreatedAt = DateTime.UtcNow, Name = "saa" });
268268
unitOfWork.DbContext.TestEntities
269269
.Add(new TestEntity() { CreatedAt = DateTime.UtcNow, Name = "saa" });
270-
await unitOfWork.CommitAsync();
270+
await unitOfWork.CommitAsync(TestContext.Current.CancellationToken);
271271
}
272272
using (var scope = Services.CreateScope())
273273
{
@@ -279,7 +279,7 @@ public async Task RollbackAsyncTest()
279279
unitOfWork.DbContext.TestEntities.Add(new TestEntity() { Name = "xxx", CreatedAt = DateTime.UtcNow });
280280
unitOfWork.DbContext.TestEntities.Add(new TestEntity() { Name = "xxx", CreatedAt = DateTime.UtcNow });
281281

282-
await unitOfWork.RollbackAsync();
282+
await unitOfWork.RollbackAsync(TestContext.Current.CancellationToken);
283283

284284
var count2 = unitOfWork.DbContext.TestEntities.Count();
285285
Assert.Equal(count, count2);
@@ -301,7 +301,7 @@ public void HybridTest()
301301
}
302302
try
303303
{
304-
_semaphore.Wait();
304+
_semaphore.Wait(TestContext.Current.CancellationToken);
305305

306306
using (var scope = Services.CreateScope())
307307
{

0 commit comments

Comments
 (0)