Skip to content
Open
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
1,888 changes: 1,888 additions & 0 deletions dotnet-install.sh

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<PackageVersion Include="NUnit3TestAdapter" Version="5.1.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
<PackageVersion Include="NUnit.Analyzers" Version="4.10.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.10.0" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) 2025 ReactiveUI and Contributors. All rights reserved.
// Licensed to reactiveui and contributors under one or more agreements.
// The reactiveui and contributors licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using Microsoft.UI.Xaml;
using NUnit.Framework;

namespace ReactiveUI.Uno.Tests.Activation;

/// <summary>
/// Contains tests for the <see cref="ActivationForViewFetcher"/> class, ensuring its functionality
/// for determining view activation affinity and providing activation observables.
/// </summary>
[TestFixture]
public class ActivationForViewFetcherTests
{
/// <summary>
/// The system under test.
/// </summary>
private ActivationForViewFetcher _sut = null!;

/// <summary>
/// Sets up the test by creating a new instance of ActivationForViewFetcher.
/// </summary>
[SetUp]
public void SetUp()
{
_sut = new ActivationForViewFetcher();
}

/// <summary>
/// Validates that GetAffinityForView returns high affinity for FrameworkElement types.
/// </summary>
[Test]
public void GetAffinityForView_ReturnsHighAffinity_ForFrameworkElementTypes()
{
var affinity = _sut.GetAffinityForView(typeof(FrameworkElement));
Assert.That(affinity, Is.EqualTo(10));
}

/// <summary>
/// Validates that GetAffinityForView returns zero affinity for non-FrameworkElement types.
/// </summary>
[Test]
public void GetAffinityForView_ReturnsZeroAffinity_ForNonFrameworkElementTypes()
{
var affinity = _sut.GetAffinityForView(typeof(object));
Assert.That(affinity, Is.Zero);
}

/// <summary>
/// Validates that GetAffinityForView returns zero affinity for string type.
/// </summary>
[Test]
public void GetAffinityForView_ReturnsZeroAffinity_ForStringType()
{
var affinity = _sut.GetAffinityForView(typeof(string));
Assert.That(affinity, Is.Zero);
}

/// <summary>
/// Validates that GetAffinityForView returns zero affinity for value types.
/// </summary>
[Test]
public void GetAffinityForView_ReturnsZeroAffinity_ForValueTypes()
{
var affinity = _sut.GetAffinityForView(typeof(int));
Assert.That(affinity, Is.Zero);
}

/// <summary>
/// Validates that GetActivationForView returns empty observable for non-FrameworkElement views.
/// </summary>
[Test]
public void GetActivationForView_ReturnsEmptyObservable_ForNonFrameworkElementViews()
{
var mockView = new MockActivatableView();
var observable = _sut.GetActivationForView(mockView);

Assert.That(observable, Is.Not.Null);
Assert.That(observable, Is.InstanceOf<IObservable<bool>>());
}

/// <summary>
/// Simple mock implementation of IActivatableView for testing.
/// </summary>
private class MockActivatableView : IActivatableView
{
public ViewModelActivator Activator { get; } = new();
}
}
77 changes: 77 additions & 0 deletions src/ReactiveUI.Uno.Tests/Bootstrapping/AppBootstrapperTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright (c) 2025 ReactiveUI and Contributors. All rights reserved.
// Licensed to reactiveui and contributors under one or more agreements.
// The reactiveui and contributors licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using NUnit.Framework;

namespace ReactiveUI.Uno.Tests.Bootstrapping;

/// <summary>
/// Contains tests for the <see cref="AppBootstrapper"/> class, ensuring its functionality
/// for application bootstrapping with ReactiveUI.
/// </summary>
[TestFixture]
public class AppBootstrapperTests
{
/// <summary>
/// Validates that AppBootstrapper can be instantiated without errors.
/// </summary>
[Test]
public void Constructor_CreatesInstance_Successfully()
{
AppBootstrapper? bootstrapper = null;

Assert.DoesNotThrow(() => bootstrapper = new AppBootstrapper());
Assert.That(bootstrapper, Is.Not.Null);
}

/// <summary>
/// Validates that AppBootstrapper implements IScreen interface.
/// </summary>
[Test]
public void AppBootstrapper_ImplementsIScreen()
{
var bootstrapper = new AppBootstrapper();
Assert.That(bootstrapper, Is.InstanceOf<IScreen>());
}

/// <summary>
/// Validates that Router property is initialized and not null.
/// </summary>
[Test]
public void Router_IsInitialized_NotNull()
{
var bootstrapper = new AppBootstrapper();
Assert.That(bootstrapper.Router, Is.Not.Null);
Assert.That(bootstrapper.Router, Is.InstanceOf<RoutingState>());
}

/// <summary>
/// Validates that AppBootstrapper inherits from ReactiveObject.
/// </summary>
[Test]
public void AppBootstrapper_InheritsFromReactiveObject()
{
var bootstrapper = new AppBootstrapper();
Assert.That(bootstrapper, Is.InstanceOf<ReactiveObject>());
}

/// <summary>
/// Validates that multiple instances can be created.
/// </summary>
[Test]
public void Constructor_AllowsMultipleInstances()
{
var bootstrapper1 = new AppBootstrapper();
var bootstrapper2 = new AppBootstrapper();

using (Assert.EnterMultipleScope())
{
Assert.That(bootstrapper1, Is.Not.Null);
Assert.That(bootstrapper2, Is.Not.Null);
Assert.That(bootstrapper1, Is.Not.SameAs(bootstrapper2));
Assert.That(bootstrapper1.Router, Is.Not.SameAs(bootstrapper2.Router));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Copyright (c) 2025 ReactiveUI and Contributors. All rights reserved.
// Licensed to reactiveui and contributors under one or more agreements.
// The reactiveui and contributors licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using NUnit.Framework;
using ReactiveUI.Builder;
using Splat;

namespace ReactiveUI.Uno.Tests.Builder;

/// <summary>
/// Contains tests for the <see cref="UnoReactiveUIBuilderExtensions"/> class, ensuring its functionality
/// for builder pattern extensions.
/// </summary>
[TestFixture]
public class UnoReactiveUIBuilderExtensionsTests
{
/// <summary>
/// Validates that BuildApp throws ArgumentNullException when builder is null.
/// </summary>
[Test]
public void BuildApp_ThrowsArgumentNullException_WhenBuilderIsNull()
{
Assert.That(
() => UnoReactiveUIBuilderExtensions.BuildApp(null!),
Throws.ArgumentNullException.With.Property("ParamName").EqualTo("builder"));
}

/// <summary>
/// Validates that WithDefaultIScreen throws ArgumentNullException when builder is null.
/// </summary>
[Test]
public void WithDefaultIScreen_ThrowsArgumentNullException_WhenBuilderIsNull()
{
Assert.That(
() => UnoReactiveUIBuilderExtensions.WithDefaultIScreen(null!),
Throws.ArgumentNullException.With.Property("ParamName").EqualTo("builder"));
}

/// <summary>
/// Validates that WithInstance throws ArgumentNullException when reactiveUIInstance is null.
/// </summary>
[Test]
public void WithInstance_ThrowsArgumentNullException_WhenReactiveUIInstanceIsNull()
{
Assert.That(
() => UnoReactiveUIBuilderExtensions.WithInstance<object>(null!, _ => { }),
Throws.ArgumentNullException.With.Property("ParamName").EqualTo("reactiveUIInstance"));
}

/// <summary>
/// Validates that WithInstance (2 types) throws ArgumentNullException when reactiveUIInstance is null.
/// </summary>
[Test]
public void WithInstance_TwoTypes_ThrowsArgumentNullException_WhenReactiveUIInstanceIsNull()
{
Assert.That(
() => UnoReactiveUIBuilderExtensions.WithInstance<object, string>(null!, (_, _) => { }),
Throws.ArgumentNullException.With.Property("ParamName").EqualTo("reactiveUIInstance"));
}

/// <summary>
/// Validates that WithInstance (3 types) throws ArgumentNullException when reactiveUIInstance is null.
/// </summary>
[Test]
public void WithInstance_ThreeTypes_ThrowsArgumentNullException_WhenReactiveUIInstanceIsNull()
{
Assert.That(
() => UnoReactiveUIBuilderExtensions.WithInstance<object, string, int>(null!, (_, _, _) => { }),
Throws.ArgumentNullException.With.Property("ParamName").EqualTo("reactiveUIInstance"));
}

/// <summary>
/// Validates that WithInstance (4 types) throws ArgumentNullException when reactiveUIInstance is null.
/// </summary>
[Test]
public void WithInstance_FourTypes_ThrowsArgumentNullException_WhenReactiveUIInstanceIsNull()
{
Assert.That(
() => UnoReactiveUIBuilderExtensions.WithInstance<object, string, int, bool>(null!, (_, _, _, _) => { }),
Throws.ArgumentNullException.With.Property("ParamName").EqualTo("reactiveUIInstance"));
}

/// <summary>
/// Validates that WithInstance (5 types) throws ArgumentNullException when reactiveUIInstance is null.
/// </summary>
[Test]
public void WithInstance_FiveTypes_ThrowsArgumentNullException_WhenReactiveUIInstanceIsNull()
{
Assert.That(
() => UnoReactiveUIBuilderExtensions.WithInstance<object, string, int, bool, double>(null!, (_, _, _, _, _) => { }),
Throws.ArgumentNullException.With.Property("ParamName").EqualTo("reactiveUIInstance"));
}
}
Loading
Loading