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
2 changes: 1 addition & 1 deletion src/tests/ReactiveUI.AOTTests/AdvancedAOTTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AdvancedAOTTests
[Test]
public async Task RoutingState_Navigation_WorksInAOT()
{
var routingState = new RoutingState();
var routingState = new RoutingState(ImmediateScheduler.Instance);
var viewModel = new TestRoutableViewModel();

// Test navigation
Expand Down
37 changes: 0 additions & 37 deletions src/tests/ReactiveUI.Builder.Maui.Tests/MauiTestFixture.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<ItemGroup>
<ProjectReference Include="..\..\ReactiveUI.Maui\ReactiveUI.Maui.csproj" />
<ProjectReference Include="..\..\ReactiveUI\ReactiveUI.csproj" />
<ProjectReference Include="..\ReactiveUI.Maui.Tests\ReactiveUI.Maui.Tests.csproj" />
</ItemGroup>

<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
Expand All @@ -30,5 +31,9 @@
<Using Include="System.Reactive.Linq" />
<Using Include="System.Threading" />
<Using Include="System.Threading.Tasks" />
<Using Include="ReactiveUI" />
<Using Include="ReactiveUI.Maui" />
<Using Include="TUnit.Core" />
<Using Include="TUnit.Core.Executors" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,18 @@

using Microsoft.Maui.Dispatching;

using ReactiveUI.Maui.Tests;

using Splat.Builder;

namespace ReactiveUI.Builder.Maui.Tests;

/// <summary>
/// Tests for ReactiveUI Builder MAUI extensions.
/// </summary>
[TestExecutor<MauiTestExecutor>]
public class ReactiveUIBuilderMauiTests
{
private readonly MauiTestFixture _fixture = new();

/// <summary>
/// Sets up the test dispatcher for MAUI controls.
/// </summary>
[Before(Test)]
public void Setup() => _fixture.Setup();

/// <summary>
/// Restores the previous dispatcher provider.
/// </summary>
[After(Test)]
public void Teardown() => _fixture.Teardown();

/// <summary>
/// Verifies that the WithMaui builder extension registers required MAUI services.
/// </summary>
Expand Down
61 changes: 61 additions & 0 deletions src/tests/ReactiveUI.Maui.Tests/MauiTestExecutor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright (c) 2025 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using Microsoft.Maui.Dispatching;
using TUnit.Core.Interfaces;

namespace ReactiveUI.Maui.Tests;

/// <summary>
/// Test executor that provides MAUI test isolation with dispatcher setup.
/// Sets up MAUI DispatcherProvider for test execution and restores state on cleanup.
/// </summary>
/// <remarks>
/// This executor provides:
/// - MAUI DispatcherProvider configuration for test execution
/// - Automatic cleanup and state restoration after test completion
/// Tests using this executor should be marked with [NotInParallel] if they modify shared state.
/// </remarks>
public class MauiTestExecutor : ITestExecutor
{
private IDispatcherProvider? _previousProvider;

/// <inheritdoc/>
public virtual async ValueTask ExecuteTest(TestContext context, Func<ValueTask> testAction)
{
ArgumentNullException.ThrowIfNull(testAction);

Initialize();

try
{
await testAction();
}
finally
{
CleanUp();
}
}

/// <summary>
/// Initializes the MAUI test environment by setting up the test dispatcher provider.
/// </summary>
protected virtual void Initialize()
{
_previousProvider = DispatcherProvider.Current;
DispatcherProvider.SetCurrent(new TestDispatcherProvider());
}

/// <summary>
/// Cleans up the MAUI test environment by restoring the previous dispatcher provider.
/// </summary>
protected virtual void CleanUp()
{
if (_previousProvider is not null)
{
DispatcherProvider.SetCurrent(_previousProvider);
}
}
}
37 changes: 0 additions & 37 deletions src/tests/ReactiveUI.Maui.Tests/MauiTestFixture.cs

This file was deleted.

15 changes: 1 addition & 14 deletions src/tests/ReactiveUI.Maui.Tests/ReactiveCarouselViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,9 @@ namespace ReactiveUI.Maui.Tests;
/// <summary>
/// Tests for ReactiveCarouselView.
/// </summary>
[TestExecutor<MauiTestExecutor>]
public class ReactiveCarouselViewTests
{
private readonly MauiTestFixture _fixture = new();

/// <summary>
/// Sets up the test dispatcher for MAUI controls.
/// </summary>
[Before(Test)]
public void Setup() => _fixture.Setup();

/// <summary>
/// Restores the previous dispatcher provider.
/// </summary>
[After(Test)]
public void Teardown() => _fixture.Teardown();

/// <summary>
/// Tests that ViewModel property can be set and retrieved.
/// </summary>
Expand Down
15 changes: 1 addition & 14 deletions src/tests/ReactiveUI.Maui.Tests/ReactiveContentPageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,9 @@ namespace ReactiveUI.Maui.Tests;
/// <summary>
/// Tests for ReactiveContentPage.
/// </summary>
[TestExecutor<MauiTestExecutor>]
public class ReactiveContentPageTests
{
private readonly MauiTestFixture _fixture = new();

/// <summary>
/// Sets up the test dispatcher for MAUI controls.
/// </summary>
[Before(Test)]
public void Setup() => _fixture.Setup();

/// <summary>
/// Restores the previous dispatcher provider.
/// </summary>
[After(Test)]
public void Teardown() => _fixture.Teardown();

/// <summary>
/// Tests that ViewModel property can be set and retrieved.
/// </summary>
Expand Down
15 changes: 1 addition & 14 deletions src/tests/ReactiveUI.Maui.Tests/ReactiveContentViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,9 @@ namespace ReactiveUI.Maui.Tests;
/// <summary>
/// Tests for ReactiveContentView.
/// </summary>
[TestExecutor<MauiTestExecutor>]
public class ReactiveContentViewTests
{
private readonly MauiTestFixture _fixture = new();

/// <summary>
/// Sets up the test dispatcher for MAUI controls.
/// </summary>
[Before(Test)]
public void Setup() => _fixture.Setup();

/// <summary>
/// Restores the previous dispatcher provider.
/// </summary>
[After(Test)]
public void Teardown() => _fixture.Teardown();

/// <summary>
/// Tests that ViewModel property can be set and retrieved.
/// </summary>
Expand Down
15 changes: 1 addition & 14 deletions src/tests/ReactiveUI.Maui.Tests/ReactiveFlyoutPageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,9 @@ namespace ReactiveUI.Maui.Tests;
/// <summary>
/// Tests for ReactiveFlyoutPage.
/// </summary>
[TestExecutor<MauiTestExecutor>]
public class ReactiveFlyoutPageTests
{
private readonly MauiTestFixture _fixture = new();

/// <summary>
/// Sets up the test dispatcher for MAUI controls.
/// </summary>
[Before(Test)]
public void Setup() => _fixture.Setup();

/// <summary>
/// Restores the previous dispatcher provider.
/// </summary>
[After(Test)]
public void Teardown() => _fixture.Teardown();

/// <summary>
/// Tests that ViewModel property can be set and retrieved.
/// </summary>
Expand Down
15 changes: 1 addition & 14 deletions src/tests/ReactiveUI.Maui.Tests/ReactiveImageItemViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,9 @@ namespace ReactiveUI.Maui.Tests;
/// <summary>
/// Tests for ReactiveImageItemView.
/// </summary>
[TestExecutor<MauiTestExecutor>]
public class ReactiveImageItemViewTests
{
private readonly MauiTestFixture _fixture = new();

/// <summary>
/// Sets up the test dispatcher for MAUI controls.
/// </summary>
[Before(Test)]
public void Setup() => _fixture.Setup();

/// <summary>
/// Restores the previous dispatcher provider.
/// </summary>
[After(Test)]
public void Teardown() => _fixture.Teardown();

/// <summary>
/// Tests that ViewModel property can be set and retrieved.
/// </summary>
Expand Down
15 changes: 1 addition & 14 deletions src/tests/ReactiveUI.Maui.Tests/ReactiveMasterDetailPageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,9 @@ namespace ReactiveUI.Maui.Tests;
/// <summary>
/// Tests for ReactiveMasterDetailPage.
/// </summary>
[TestExecutor<MauiTestExecutor>]
public class ReactiveMasterDetailPageTests
{
private readonly MauiTestFixture _fixture = new();

/// <summary>
/// Sets up the test dispatcher for MAUI controls.
/// </summary>
[Before(Test)]
public void Setup() => _fixture.Setup();

/// <summary>
/// Restores the previous dispatcher provider.
/// </summary>
[After(Test)]
public void Teardown() => _fixture.Teardown();

/// <summary>
/// Tests that ViewModel property can be set and retrieved.
/// </summary>
Expand Down
15 changes: 1 addition & 14 deletions src/tests/ReactiveUI.Maui.Tests/ReactiveMultiPageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,9 @@ namespace ReactiveUI.Maui.Tests;
/// <summary>
/// Tests for ReactiveMultiPage.
/// </summary>
[TestExecutor<MauiTestExecutor>]
public class ReactiveMultiPageTests
{
private readonly MauiTestFixture _fixture = new();

/// <summary>
/// Sets up the test dispatcher for MAUI controls.
/// </summary>
[Before(Test)]
public void Setup() => _fixture.Setup();

/// <summary>
/// Restores the previous dispatcher provider.
/// </summary>
[After(Test)]
public void Teardown() => _fixture.Teardown();

/// <summary>
/// Tests that ViewModel property can be set and retrieved.
/// </summary>
Expand Down
15 changes: 1 addition & 14 deletions src/tests/ReactiveUI.Maui.Tests/ReactiveNavigationPageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,9 @@ namespace ReactiveUI.Maui.Tests;
/// <summary>
/// Tests for ReactiveNavigationPage.
/// </summary>
[TestExecutor<MauiTestExecutor>]
public class ReactiveNavigationPageTests
{
private readonly MauiTestFixture _fixture = new();

/// <summary>
/// Sets up the test dispatcher for MAUI controls.
/// </summary>
[Before(Test)]
public void Setup() => _fixture.Setup();

/// <summary>
/// Restores the previous dispatcher provider.
/// </summary>
[After(Test)]
public void Teardown() => _fixture.Teardown();

/// <summary>
/// Tests that ViewModel property can be set and retrieved.
/// </summary>
Expand Down
Loading
Loading