Skip to content

Commit c7570a6

Browse files
Migrate test projects from xUnit to NUnit 4.4.0 (#99)
Co-authored-by: glennawatson <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]>
1 parent 4b71334 commit c7570a6

File tree

6 files changed

+46
-60
lines changed

6 files changed

+46
-60
lines changed

src/Directory.Packages.props

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
<ItemGroup>
2222
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
2323
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
24-
<PackageVersion Include="FluentAssertions" Version="8.8.0" />
25-
<PackageVersion Include="FluentAssertions.Analyzers" Version="0.34.1" />
26-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
24+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
2725
<PackageVersion Include="Microsoft.Reactive.Testing" Version="6.1.0" />
28-
<PackageVersion Include="xunit" Version="2.9.3" />
29-
<PackageVersion Include="xunit.analyzers" Version="1.25.0" />
30-
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
26+
<PackageVersion Include="NUnit" Version="4.4.0" />
27+
<PackageVersion Include="NUnit3TestAdapter" Version="5.2.0" />
28+
<PackageVersion Include="NUnit.Analyzers" Version="4.11.2" />
3129
</ItemGroup>
3230

3331
<Import
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (c) 2019-2025 ReactiveUI Association Incorporated. All rights reserved.
2+
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for full license information.
4+
5+
using NUnit.Framework;
6+
7+
[assembly: Parallelizable(ParallelScope.Fixtures)]
8+
[assembly: LevelOfParallelism(4)]

src/ReactiveUI.Extensions.Tests/DisposableExtensionsTests.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
using System;
66
using System.Reactive.Disposables;
77
using System.Reactive.Disposables.Fluent;
8-
using FluentAssertions;
9-
using Xunit;
8+
using NUnit.Framework;
109

1110
namespace ReactiveUI.Extensions.Tests;
1211

@@ -18,25 +17,23 @@ public class DisposableExtensionsTests
1817
/// <summary>
1918
/// Tests DisposeWith returns a disposable.
2019
/// </summary>
21-
[Fact]
20+
[Test]
2221
public void GivenNull_WhenDisposeWith_ThenExceptionThrown()
2322
{
2423
// Given
2524
var sut = Disposable.Create(() => { });
2625

2726
// When
28-
var result = Record.Exception(() => sut.DisposeWith(null!));
27+
var result = Assert.Catch<Exception>(() => sut.DisposeWith(null!));
2928

3029
// Then
31-
result
32-
.Should()
33-
.BeOfType<ArgumentNullException>();
30+
Assert.That(result, Is.TypeOf<ArgumentNullException>());
3431
}
3532

3633
/// <summary>
3734
/// Tests DisposeWith disposes the underlying disposable.
3835
/// </summary>
39-
[Fact]
36+
[Test]
4037
public void GivenDisposable_WhenDisposeWith_ThenDisposed()
4138
{
4239
// Given
@@ -48,15 +45,13 @@ public void GivenDisposable_WhenDisposeWith_ThenDisposed()
4845
compositeDisposable.Dispose();
4946

5047
// Then
51-
sut.IsDisposed
52-
.Should()
53-
.BeTrue();
48+
Assert.That(sut.IsDisposed, Is.True);
5449
}
5550

5651
/// <summary>
5752
/// Tests DisposeWith returns the original disposable.
5853
/// </summary>
59-
[Fact]
54+
[Test]
6055
public void GivenDisposable_WhenDisposeWith_ThenReturnsDisposable()
6156
{
6257
// Given, When
@@ -65,7 +60,6 @@ public void GivenDisposable_WhenDisposeWith_ThenReturnsDisposable()
6560
var result = sut.DisposeWith(compositeDisposable);
6661

6762
// Then
68-
sut.Should()
69-
.BeEquivalentTo(result);
63+
Assert.That(result, Is.SameAs(sut));
7064
}
7165
}

src/ReactiveUI.Extensions.Tests/ReactiveExtensionsTests.cs

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
using System.Reactive.Subjects;
99
using System.Threading;
1010
using System.Threading.Tasks;
11-
using FluentAssertions;
12-
using Xunit;
11+
using NUnit.Framework;
1312

1413
namespace ReactiveUI.Extensions.Tests;
1514

@@ -21,55 +20,49 @@ public class ReactiveExtensionsTests
2120
/// <summary>
2221
/// Tests the WhereIsNotNull extension.
2322
/// </summary>
24-
[Fact]
23+
[Test]
2524
public void GivenNull_WhenWhereIsNotNull_ThenNoNotification()
2625
{
2726
// Given, When
2827
bool? result = null;
2928
using var disposable = Observable.Return<bool?>(null).WhereIsNotNull().Subscribe(x => result = x);
3029

3130
// Then
32-
result
33-
.Should()
34-
.BeNull();
31+
Assert.That(result, Is.Null);
3532
}
3633

3734
/// <summary>
3835
/// Tests the WhereIsNotNull extension.
3936
/// </summary>
40-
[Fact]
37+
[Test]
4138
public void GivenValue_WhenWhereIsNotNull_ThenNotification()
4239
{
4340
// Given, When
4441
bool? result = null;
4542
using var disposable = Observable.Return<bool?>(false).WhereIsNotNull().Subscribe(x => result = x);
4643

4744
// Then
48-
result
49-
.Should()
50-
.BeFalse();
45+
Assert.That(result, Is.False);
5146
}
5247

5348
/// <summary>
5449
/// Tests the AsSignal extension.
5550
/// </summary>
56-
[Fact]
51+
[Test]
5752
public void GivenObservable_WhenAsSignal_ThenNotifiesUnit()
5853
{
5954
// Given, When
6055
Unit? result = null;
6156
using var disposable = Observable.Return<bool?>(false).AsSignal().Subscribe(x => result = x);
6257

6358
// Then
64-
result
65-
.Should()
66-
.Be(Unit.Default);
59+
Assert.That(result, Is.EqualTo(Unit.Default));
6760
}
6861

6962
/// <summary>
7063
/// Syncronizes the asynchronous runs with asynchronous tasks in subscriptions.
7164
/// </summary>
72-
[Fact]
65+
[Test]
7366
public void SubscribeSynchronus_RunsWithAsyncTasksInSubscriptions()
7467
{
7568
// Given, When
@@ -106,15 +99,13 @@ public void SubscribeSynchronus_RunsWithAsyncTasksInSubscriptions()
10699
}
107100

108101
// Then
109-
result
110-
.Should()
111-
.Be(0);
102+
Assert.That(result, Is.Zero);
112103
}
113104

114105
/// <summary>
115106
/// Syncronizes the asynchronous runs with asynchronous tasks in subscriptions.
116107
/// </summary>
117-
[Fact]
108+
[Test]
118109
public void SyncronizeAsync_RunsWithAsyncTasksInSubscriptions()
119110
{
120111
// Given, When
@@ -153,15 +144,13 @@ public void SyncronizeAsync_RunsWithAsyncTasksInSubscriptions()
153144
}
154145

155146
// Then
156-
result
157-
.Should()
158-
.Be(0);
147+
Assert.That(result, Is.Zero);
159148
}
160149

161150
/// <summary>
162151
/// Syncronizes the asynchronous runs with asynchronous tasks in subscriptions.
163152
/// </summary>
164-
[Fact]
153+
[Test]
165154
public void SynchronizeSynchronous_RunsWithAsyncTasksInSubscriptions()
166155
{
167156
// Given, When
@@ -200,15 +189,13 @@ public void SynchronizeSynchronous_RunsWithAsyncTasksInSubscriptions()
200189
}
201190

202191
// Then
203-
result
204-
.Should()
205-
.Be(0);
192+
Assert.That(result, Is.Zero);
206193
}
207194

208195
/// <summary>
209196
/// Syncronizes the asynchronous runs with asynchronous tasks in subscriptions.
210197
/// </summary>
211-
[Fact]
198+
[Test]
212199
public void SubscribeAsync_RunsWithAsyncTasksInSubscriptions()
213200
{
214201
// Given, When
@@ -245,8 +232,6 @@ public void SubscribeAsync_RunsWithAsyncTasksInSubscriptions()
245232
}
246233

247234
// Then
248-
result
249-
.Should()
250-
.Be(0);
235+
Assert.That(result, Is.Zero);
251236
}
252237
}

src/ReactiveUI.Extensions.Tests/ReactiveUI.Extensions.Tests.csproj

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="FluentAssertions" />
109
<PackageReference Include="Microsoft.NET.Test.Sdk" />
1110
<PackageReference Include="Microsoft.Reactive.Testing" />
12-
<PackageReference Include="xunit" />
13-
<PackageReference Include="xunit.runner.visualstudio">
14-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15-
<PrivateAssets>all</PrivateAssets>
16-
</PackageReference>
17-
<PackageReference Include="coverlet.collector">
18-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19-
<PrivateAssets>all</PrivateAssets>
20-
</PackageReference>
11+
<PackageReference Include="NUnit" />
12+
<PackageReference Include="NUnit3TestAdapter" />
13+
<PackageReference Include="coverlet.collector" PrivateAssets="all" />
14+
<PackageReference Include="coverlet.msbuild" />
15+
<PackageReference Include="NUnit.Analyzers" PrivateAssets="all" />
2116
</ItemGroup>
2217

2318
<ItemGroup>

tests.runsettings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RunSettings>
3+
<NUnit>
4+
<NumberOfTestWorkers>4</NumberOfTestWorkers>
5+
</NUnit>
6+
</RunSettings>

0 commit comments

Comments
 (0)