Skip to content

Commit 8bfb585

Browse files
committed
refactor: use xunit v3
1 parent 9958636 commit 8bfb585

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

test/WeihanLi.EntityFramework.Test/EFRepositoryTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using WeihanLi.Common;
44
using WeihanLi.Common.Helpers;
55
using Xunit;
6-
using Xunit.Abstractions;
76

87
namespace WeihanLi.EntityFramework.Test;
98

@@ -40,7 +39,7 @@ public void InsertTest()
4039
[Fact]
4140
public async Task InsertAsyncTest()
4241
{
43-
using (await _lock.LockAsync())
42+
using (await _lock.LockAsync(cancellationToken: TestContext.Current.CancellationToken))
4443
{
4544
await DependencyResolver.TryInvokeAsync<IEFRepository<TestDbContext, TestEntity>>(async repo =>
4645
{

test/WeihanLi.EntityFramework.Test/EFUnitOfWorkTest.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Threading.Tasks;
77
using WeihanLi.Common.Data;
88
using Xunit;
9-
using Xunit.Abstractions;
109

1110
namespace WeihanLi.EntityFramework.Test;
1211

@@ -193,13 +192,13 @@ await repo.InsertAsync(new TestEntity()
193192

194193
await uow.CommitAsync();
195194

196-
var committedCount = await repository.CountAsync();
195+
var committedCount = await repository.CountAsync(cancellationToken: TestContext.Current.CancellationToken);
197196
Assert.Equal(committedCount, beforeCount + 1);
198197

199198
entity = await repository.DbContext.FindAsync<TestEntity>(3);
200199
Assert.Equal(new string('3', 6), entity.Name);
201200

202-
entity = await repository.DbContext.FindAsync<TestEntity>(new object[] { 4 }, CancellationToken.None);
201+
entity = await repository.DbContext.FindAsync<TestEntity>(new object[] { 4 }, cancellationToken: TestContext.Current.CancellationToken);
203202
Assert.Equal(new string('4', 6), entity.Name);
204203

205204
Assert.Equal(1, await Repository.DeleteAsync(1));

test/WeihanLi.EntityFramework.Test/WeihanLi.EntityFramework.Test.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
<PropertyGroup>
44
<IsTestProject>true</IsTestProject>
55
<IsPackable>false</IsPackable>
6+
<OutputType>exe</OutputType>
67
<Nullable>disable</Nullable>
8+
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
9+
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
710
</PropertyGroup>
811

912
<ItemGroup>
1013
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(EFVersion)" />
1114
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(EFVersion)" />
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
13-
<PackageReference Include="xunit" Version="2.9.2" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
16+
<PackageReference Include="xunit.v3" Version="2.0.0" />
1417
</ItemGroup>
1518

1619
<ItemGroup>

0 commit comments

Comments
 (0)