Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
<ItemGroup>
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
<PackageVersion Include="FluentAssertions" Version="8.8.0" />
<PackageVersion Include="FluentAssertions.Analyzers" Version="0.34.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="Microsoft.Reactive.Testing" Version="6.1.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.analyzers" Version="1.25.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="NUnit" Version="4.4.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="5.2.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.11.2" />
</ItemGroup>

<Import
Expand Down
8 changes: 8 additions & 0 deletions src/ReactiveUI.Extensions.Tests/AssemblyInfo.Parallel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) 2019-2025 ReactiveUI Association Incorporated. All rights reserved.
// ReactiveUI Association Incorporated licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using NUnit.Framework;

[assembly: Parallelizable(ParallelScope.Fixtures)]
[assembly: LevelOfParallelism(4)]
22 changes: 8 additions & 14 deletions src/ReactiveUI.Extensions.Tests/DisposableExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
using System;
using System.Reactive.Disposables;
using System.Reactive.Disposables.Fluent;
using FluentAssertions;
using Xunit;
using NUnit.Framework;

namespace ReactiveUI.Extensions.Tests;

Expand All @@ -18,25 +17,23 @@ public class DisposableExtensionsTests
/// <summary>
/// Tests DisposeWith returns a disposable.
/// </summary>
[Fact]
[Test]
public void GivenNull_WhenDisposeWith_ThenExceptionThrown()
{
// Given
var sut = Disposable.Create(() => { });

// When
var result = Record.Exception(() => sut.DisposeWith(null!));
var result = Assert.Catch<Exception>(() => sut.DisposeWith(null!));

// Then
result
.Should()
.BeOfType<ArgumentNullException>();
Assert.That(result, Is.TypeOf<ArgumentNullException>());
}

/// <summary>
/// Tests DisposeWith disposes the underlying disposable.
/// </summary>
[Fact]
[Test]
public void GivenDisposable_WhenDisposeWith_ThenDisposed()
{
// Given
Expand All @@ -48,15 +45,13 @@ public void GivenDisposable_WhenDisposeWith_ThenDisposed()
compositeDisposable.Dispose();

// Then
sut.IsDisposed
.Should()
.BeTrue();
Assert.That(sut.IsDisposed, Is.True);
}

/// <summary>
/// Tests DisposeWith returns the original disposable.
/// </summary>
[Fact]
[Test]
public void GivenDisposable_WhenDisposeWith_ThenReturnsDisposable()
{
// Given, When
Expand All @@ -65,7 +60,6 @@ public void GivenDisposable_WhenDisposeWith_ThenReturnsDisposable()
var result = sut.DisposeWith(compositeDisposable);

// Then
sut.Should()
.BeEquivalentTo(result);
Assert.That(result, Is.SameAs(sut));
}
}
45 changes: 15 additions & 30 deletions src/ReactiveUI.Extensions.Tests/ReactiveExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
using System.Reactive.Subjects;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Xunit;
using NUnit.Framework;

namespace ReactiveUI.Extensions.Tests;

Expand All @@ -21,55 +20,49 @@ public class ReactiveExtensionsTests
/// <summary>
/// Tests the WhereIsNotNull extension.
/// </summary>
[Fact]
[Test]
public void GivenNull_WhenWhereIsNotNull_ThenNoNotification()
{
// Given, When
bool? result = null;
using var disposable = Observable.Return<bool?>(null).WhereIsNotNull().Subscribe(x => result = x);

// Then
result
.Should()
.BeNull();
Assert.That(result, Is.Null);
}

/// <summary>
/// Tests the WhereIsNotNull extension.
/// </summary>
[Fact]
[Test]
public void GivenValue_WhenWhereIsNotNull_ThenNotification()
{
// Given, When
bool? result = null;
using var disposable = Observable.Return<bool?>(false).WhereIsNotNull().Subscribe(x => result = x);

// Then
result
.Should()
.BeFalse();
Assert.That(result, Is.False);
}

/// <summary>
/// Tests the AsSignal extension.
/// </summary>
[Fact]
[Test]
public void GivenObservable_WhenAsSignal_ThenNotifiesUnit()
{
// Given, When
Unit? result = null;
using var disposable = Observable.Return<bool?>(false).AsSignal().Subscribe(x => result = x);

// Then
result
.Should()
.Be(Unit.Default);
Assert.That(result, Is.EqualTo(Unit.Default));
}

/// <summary>
/// Syncronizes the asynchronous runs with asynchronous tasks in subscriptions.
/// </summary>
[Fact]
[Test]
public void SubscribeSynchronus_RunsWithAsyncTasksInSubscriptions()
{
// Given, When
Expand Down Expand Up @@ -106,15 +99,13 @@ public void SubscribeSynchronus_RunsWithAsyncTasksInSubscriptions()
}

// Then
result
.Should()
.Be(0);
Assert.That(result, Is.Zero);
}

/// <summary>
/// Syncronizes the asynchronous runs with asynchronous tasks in subscriptions.
/// </summary>
[Fact]
[Test]
public void SyncronizeAsync_RunsWithAsyncTasksInSubscriptions()
{
// Given, When
Expand Down Expand Up @@ -153,15 +144,13 @@ public void SyncronizeAsync_RunsWithAsyncTasksInSubscriptions()
}

// Then
result
.Should()
.Be(0);
Assert.That(result, Is.Zero);
}

/// <summary>
/// Syncronizes the asynchronous runs with asynchronous tasks in subscriptions.
/// </summary>
[Fact]
[Test]
public void SynchronizeSynchronous_RunsWithAsyncTasksInSubscriptions()
{
// Given, When
Expand Down Expand Up @@ -200,15 +189,13 @@ public void SynchronizeSynchronous_RunsWithAsyncTasksInSubscriptions()
}

// Then
result
.Should()
.Be(0);
Assert.That(result, Is.Zero);
}

/// <summary>
/// Syncronizes the asynchronous runs with asynchronous tasks in subscriptions.
/// </summary>
[Fact]
[Test]
public void SubscribeAsync_RunsWithAsyncTasksInSubscriptions()
{
// Given, When
Expand Down Expand Up @@ -245,8 +232,6 @@ public void SubscribeAsync_RunsWithAsyncTasksInSubscriptions()
}

// Then
result
.Should()
.Be(0);
Assert.That(result, Is.Zero);
}
}
15 changes: 5 additions & 10 deletions src/ReactiveUI.Extensions.Tests/ReactiveUI.Extensions.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Reactive.Testing" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="coverlet.collector" PrivateAssets="all" />
<PackageReference Include="coverlet.msbuild" />
<PackageReference Include="NUnit.Analyzers" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions tests.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<NUnit>
<NumberOfTestWorkers>4</NumberOfTestWorkers>
</NUnit>
</RunSettings>
Loading