Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void ShowPopupAsync_Shell_WithViewType_ShowsPopup()
var shellNavigation = Shell.Current.Navigation;

// Act
shell.ShowPopup(viewWithQueryable, shellParameters: shellParameters);
shell.ShowPopup(viewWithQueryable, parameters: shellParameters);

// Assert
Assert.Single(shellNavigation.ModalStack);
Expand All @@ -231,8 +231,8 @@ public async Task ShowPopupAsync_AwaitingShowPopupAsync_EnsurePreviousPopupClose
var selfClosingPopup = ServiceProvider.GetRequiredService<MockSelfClosingPopup>() ?? throw new InvalidOperationException();

// Act
await navigation.ShowPopupAsync<object?>(selfClosingPopup, PopupOptions.Empty, TestContext.Current.CancellationToken);
await navigation.ShowPopupAsync<object?>(selfClosingPopup, PopupOptions.Empty, TestContext.Current.CancellationToken);
await navigation.ShowPopupAsync<object?>(selfClosingPopup, PopupOptions.Empty, token: TestContext.Current.CancellationToken);
await navigation.ShowPopupAsync<object?>(selfClosingPopup, PopupOptions.Empty, token: TestContext.Current.CancellationToken);

// Assert
Assert.Empty(navigation.ModalStack);
Expand Down Expand Up @@ -289,7 +289,7 @@ public void ShowPopup_Shell_NavigationModalStackCountIncreases()
Assert.Empty(shellNavigation.ModalStack);

// Act
shell.ShowPopup(viewWithQueryable, shellParameters: shellParameters);
shell.ShowPopup(viewWithQueryable, parameters: shellParameters);

// Assert
Assert.Single(shellNavigation.ModalStack);
Expand Down Expand Up @@ -720,7 +720,7 @@ public async Task ShowPopupAsync_CancellationTokenExpired()
await Task.Delay(100, TestContext.Current.CancellationToken); // Ensure CancellationToken has expired

// Assert
await Assert.ThrowsAsync<OperationCanceledException>(() => navigation.ShowPopupAsync(selfClosingPopup, PopupOptions.Empty, cts.Token));
await Assert.ThrowsAsync<OperationCanceledException>(() => navigation.ShowPopupAsync(selfClosingPopup, PopupOptions.Empty, token: cts.Token));
}

[Fact(Timeout = (int)TestDuration.Short)]
Expand Down Expand Up @@ -757,7 +757,7 @@ public async Task ShowPopupAsyncWithView_CancellationTokenExpired()
await Task.Delay(100, TestContext.Current.CancellationToken); // Ensure CancellationToken has expired

// Assert
await Assert.ThrowsAsync<OperationCanceledException>(() => navigation.ShowPopupAsync(view, PopupOptions.Empty, cts.Token));
await Assert.ThrowsAsync<OperationCanceledException>(() => navigation.ShowPopupAsync(view, PopupOptions.Empty, token: cts.Token));
}

[Fact(Timeout = (int)TestDuration.Short)]
Expand Down Expand Up @@ -795,7 +795,7 @@ public async Task ShowPopupAsync_CancellationTokenCanceled()
await cts.CancelAsync(); // Ensure CancellationToken has expired

// Assert
await Assert.ThrowsAsync<OperationCanceledException>(() => navigation.ShowPopupAsync(selfClosingPopup, PopupOptions.Empty, cts.Token));
await Assert.ThrowsAsync<OperationCanceledException>(() => navigation.ShowPopupAsync(selfClosingPopup, PopupOptions.Empty, token: cts.Token));
}

[Fact(Timeout = (int)TestDuration.Short)]
Expand All @@ -817,7 +817,7 @@ public async Task ShowPopupAsync_Shell_CancellationTokenCanceled()
await cts.CancelAsync();

// Assert
await Assert.ThrowsAsync<OperationCanceledException>(() => navigation.ShowPopupAsync(selfClosingPopup, PopupOptions.Empty, cts.Token));
await Assert.ThrowsAsync<OperationCanceledException>(() => navigation.ShowPopupAsync(selfClosingPopup, PopupOptions.Empty, token: cts.Token));
Assert.NotEqual(shellParameterBackgroundColorValue, selfClosingPopup.BackgroundColor);
}

Expand All @@ -832,7 +832,7 @@ public async Task ShowPopupAsyncWithView_CancellationTokenCanceled()
await cts.CancelAsync(); // Ensure CancellationToken has expired

// Assert
await Assert.ThrowsAsync<OperationCanceledException>(() => navigation.ShowPopupAsync(view, PopupOptions.Empty, cts.Token));
await Assert.ThrowsAsync<OperationCanceledException>(() => navigation.ShowPopupAsync(view, PopupOptions.Empty, token: cts.Token));
}

[Fact(Timeout = (int)TestDuration.Short)]
Expand Down Expand Up @@ -868,7 +868,7 @@ public async Task ShowPopupAsync_ShouldValidateProperBindingContext()
var popupViewModel = ServiceProvider.GetRequiredService<MockPageViewModel>();

// Act
await navigation.ShowPopupAsync<object?>(selfClosingPopup, PopupOptions.Empty, TestContext.Current.CancellationToken);
await navigation.ShowPopupAsync<object?>(selfClosingPopup, PopupOptions.Empty, token: TestContext.Current.CancellationToken);

// Assert
Assert.Same(popupInstance.BindingContext, popupViewModel);
Expand Down Expand Up @@ -906,7 +906,7 @@ public async Task ShowPopupAsyncWithView_ShouldValidateProperBindingContext()
var popupViewModel = ServiceProvider.GetRequiredService<MockPageViewModel>();

// Act
var showPopupTask = navigation.ShowPopupAsync<object?>(view, PopupOptions.Empty, TestContext.Current.CancellationToken);
var showPopupTask = navigation.ShowPopupAsync<object?>(view, PopupOptions.Empty, token: TestContext.Current.CancellationToken);

var popupPage = (PopupPage)navigation.ModalStack[0];

Expand Down Expand Up @@ -954,7 +954,7 @@ public async Task ShowPopupAsync_ShouldReturnResultOnceClosed()
var selfClosingPopup = ServiceProvider.GetRequiredService<MockSelfClosingPopup>() ?? throw new InvalidOperationException();

// Act
var result = await navigation.ShowPopupAsync<object?>(selfClosingPopup, PopupOptions.Empty, TestContext.Current.CancellationToken);
var result = await navigation.ShowPopupAsync<object?>(selfClosingPopup, PopupOptions.Empty, token: TestContext.Current.CancellationToken);

// Assert
Assert.Same(mockPopup.Result, result.Result);
Expand Down Expand Up @@ -994,7 +994,7 @@ public async Task ShowPopupAsyncWithView_ShouldReturnResultOnceClosed()
var expectedPopupResult = new PopupResult<int>(popupResultValue, false);

// Act
var showPopupTask = navigation.ShowPopupAsync<int>(view, PopupOptions.Empty, TestContext.Current.CancellationToken);
var showPopupTask = navigation.ShowPopupAsync<int>(view, PopupOptions.Empty, token: TestContext.Current.CancellationToken);

var popupPage = (PopupPage)navigation.ModalStack[0];

Expand Down Expand Up @@ -1044,7 +1044,7 @@ public async Task ShowPopupAsync_ShouldThrowArgumentNullException_WhenViewIsNull

// Act/Assert
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
await Assert.ThrowsAsync<ArgumentNullException>(() => navigation.ShowPopupAsync(null, PopupOptions.Empty, TestContext.Current.CancellationToken));
await Assert.ThrowsAsync<ArgumentNullException>(() => navigation.ShowPopupAsync(null, PopupOptions.Empty, token: TestContext.Current.CancellationToken));
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
}

Expand Down Expand Up @@ -1074,7 +1074,7 @@ public async Task ShowPopupAsync_ShouldThrowArgumentNullException_WhenNavigation

// Act / Assert
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
await Assert.ThrowsAsync<ArgumentNullException>(() => PopupExtensions.ShowPopupAsync((INavigation?)null, selfClosingPopup, PopupOptions.Empty, TestContext.Current.CancellationToken));
await Assert.ThrowsAsync<ArgumentNullException>(() => PopupExtensions.ShowPopupAsync((INavigation?)null, selfClosingPopup, PopupOptions.Empty, token: TestContext.Current.CancellationToken));
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
}

Expand Down Expand Up @@ -1103,7 +1103,7 @@ public async Task ShowPopupAsync_ShouldReturnNullResult_WhenPopupIsClosedWithout
// Arrange

// Act
var showPopupTask = navigation.ShowPopupAsync<object?>(new Popup(), PopupOptions.Empty, TestContext.Current.CancellationToken);
var showPopupTask = navigation.ShowPopupAsync<object?>(new Popup(), PopupOptions.Empty, token: TestContext.Current.CancellationToken);

var popupPage = (PopupPage)navigation.ModalStack.Last();
await popupPage.CloseAsync(new PopupResult(true), TestContext.Current.CancellationToken);
Expand Down
28 changes: 14 additions & 14 deletions src/CommunityToolkit.Maui.UnitTests/Services/PopupServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public async Task ShowPopupAsync_AwaitingShowPopupAsync_EnsurePreviousPopupClose
var popupService = ServiceProvider.GetRequiredService<IPopupService>();

// Act
await popupService.ShowPopupAsync<MockSelfClosingPopup>(navigation, PopupOptions.Empty, CancellationToken.None);
await popupService.ShowPopupAsync<MockSelfClosingPopup>(navigation, PopupOptions.Empty, CancellationToken.None);
await popupService.ShowPopupAsync<MockSelfClosingPopup>(navigation, PopupOptions.Empty, cancellationToken: CancellationToken.None);
await popupService.ShowPopupAsync<MockSelfClosingPopup>(navigation, PopupOptions.Empty, cancellationToken: CancellationToken.None);

// Assert
Assert.Empty(navigation.ModalStack);
Expand All @@ -109,8 +109,8 @@ public async Task ShowPopupAsync_UsingPage_AwaitingShowPopupAsync_EnsurePrevious
}

// Act
await popupService.ShowPopupAsync<MockSelfClosingPopup>(page, PopupOptions.Empty, CancellationToken.None);
await popupService.ShowPopupAsync<MockSelfClosingPopup>(page, PopupOptions.Empty, CancellationToken.None);
await popupService.ShowPopupAsync<MockSelfClosingPopup>(page, PopupOptions.Empty, cancellationToken: CancellationToken.None);
await popupService.ShowPopupAsync<MockSelfClosingPopup>(page, PopupOptions.Empty, cancellationToken: CancellationToken.None);

// Assert
Assert.Empty(navigation.ModalStack);
Expand Down Expand Up @@ -194,7 +194,7 @@ public async Task ShowPopupAsyncWithNotRegisteredServiceShouldThrowInvalidOperat
}

// Act // Assert
await Assert.ThrowsAsync<InvalidOperationException>(() => popupService.ShowPopupAsync<INotifyPropertyChanged>(page.Navigation, PopupOptions.Empty, TestContext.Current.CancellationToken));
await Assert.ThrowsAsync<InvalidOperationException>(() => popupService.ShowPopupAsync<INotifyPropertyChanged>(page.Navigation, PopupOptions.Empty, cancellationToken: TestContext.Current.CancellationToken));
}

[Fact(Timeout = (int)TestDuration.Short)]
Expand All @@ -213,7 +213,7 @@ public async Task ShowPopupAsync_CancellationTokenExpired()
}

// Assert
await Assert.ThrowsAsync<OperationCanceledException>(() => popupService.ShowPopupAsync<MockPageViewModel>(page.Navigation, PopupOptions.Empty, cts.Token));
await Assert.ThrowsAsync<OperationCanceledException>(() => popupService.ShowPopupAsync<MockPageViewModel>(page.Navigation, PopupOptions.Empty, cancellationToken: cts.Token));
}

[Fact(Timeout = (int)TestDuration.Short)]
Expand All @@ -227,7 +227,7 @@ public async Task ShowPopupAsync_CancellationTokenCanceled()
await cts.CancelAsync();

// Assert
await Assert.ThrowsAsync<OperationCanceledException>(() => popupService.ShowPopupAsync<MockPageViewModel>(navigation, PopupOptions.Empty, cts.Token));
await Assert.ThrowsAsync<OperationCanceledException>(() => popupService.ShowPopupAsync<MockPageViewModel>(navigation, PopupOptions.Empty, cancellationToken: cts.Token));
}

[Fact(Timeout = (int)TestDuration.Medium)]
Expand All @@ -244,7 +244,7 @@ public async Task ShowPopupAsyncShouldValidateProperBindingContext()
}

// Act
await popupService.ShowPopupAsync<MockPageViewModel, object?>(page.Navigation, PopupOptions.Empty, TestContext.Current.CancellationToken);
await popupService.ShowPopupAsync<MockPageViewModel, object?>(page.Navigation, PopupOptions.Empty, cancellationToken: TestContext.Current.CancellationToken);


// Assert
Expand All @@ -264,7 +264,7 @@ public async Task ShowPopupAsyncShouldReturnResultOnceClosed()
}

// Act
var result = await popupService.ShowPopupAsync<MockPageViewModel, object?>(page.Navigation, PopupOptions.Empty, CancellationToken.None);
var result = await popupService.ShowPopupAsync<MockPageViewModel, object?>(page.Navigation, PopupOptions.Empty, cancellationToken: CancellationToken.None);

// Assert
Assert.Same(mockPopup.Result, result.Result);
Expand All @@ -283,7 +283,7 @@ public async Task ShowPopupTAsyncShouldReturnResultOnceClosed()
}

// Act
var result = await popupService.ShowPopupAsync<MockPageViewModel>(page.Navigation, PopupOptions.Empty, CancellationToken.None);
var result = await popupService.ShowPopupAsync<MockPageViewModel>(page.Navigation, PopupOptions.Empty, cancellationToken: CancellationToken.None);

// Assert
Assert.False(result.WasDismissedByTappingOutsideOfPopup);
Expand All @@ -297,7 +297,7 @@ public async Task ShowPopupAsync_UsingNavigation_ShouldThrowArgumentNullExceptio

// Act // Assert
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
await Assert.ThrowsAsync<ArgumentNullException>(() => popupService.ShowPopupAsync<MockPageViewModel>((INavigation?)null, PopupOptions.Empty, CancellationToken.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => popupService.ShowPopupAsync<MockPageViewModel>((INavigation?)null, PopupOptions.Empty, cancellationToken: CancellationToken.None));
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
}

Expand All @@ -309,7 +309,7 @@ public async Task ShowPopupAsync_UsingPage_ShouldThrowArgumentNullException_When

// Act // Assert
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
await Assert.ThrowsAsync<ArgumentNullException>(() => popupService.ShowPopupAsync<MockPageViewModel>((Page?)null, PopupOptions.Empty, CancellationToken.None));
await Assert.ThrowsAsync<ArgumentNullException>(() => popupService.ShowPopupAsync<MockPageViewModel>((Page?)null, PopupOptions.Empty, cancellationToken: CancellationToken.None));
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
}

Expand Down Expand Up @@ -389,7 +389,7 @@ public async Task ShowPopupAsync_ShouldThrowArgumentNullException_WhenViewModelI
}

// Act // Assert
await Assert.ThrowsAsync<InvalidOperationException>(() => popupService.ShowPopupAsync<object>(page.Navigation, PopupOptions.Empty, CancellationToken.None));
await Assert.ThrowsAsync<InvalidOperationException>(() => popupService.ShowPopupAsync<object>(page.Navigation, PopupOptions.Empty, cancellationToken: CancellationToken.None));
}

[Fact(Timeout = (int)TestDuration.Short)]
Expand All @@ -405,7 +405,7 @@ public async Task ShowPopupAsync_ShouldReturnDefaultResult_WhenPopupIsClosedWith
}

// Act
var result = await popupService.ShowPopupAsync<MockPageViewModel, object?>(page.Navigation, PopupOptions.Empty, CancellationToken.None);
var result = await popupService.ShowPopupAsync<MockPageViewModel, object?>(page.Navigation, PopupOptions.Empty, cancellationToken: CancellationToken.None);

// Assert
Assert.Equal(mockPopup.Result, result.Result);
Expand Down
Loading
Loading