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 tests/Core/Components.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<IsPackable>false</IsPackable>
<AssemblyName>Microsoft.FluentUI.AspNetCore.Components.Tests</AssemblyName>
<RootNamespace>Microsoft.FluentUI.AspNetCore.Components.Tests</RootNamespace>
<NoWarn>xUnit1069;BL0016</NoWarn>
<NoWarn>BL0016</NoWarn>
</PropertyGroup>
Comment thread
dvoituron marked this conversation as resolved.

<ItemGroup>
Expand Down
38 changes: 38 additions & 0 deletions tests/Core/Components/Dialog/FluentDialogTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_Render()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand All @@ -52,6 +54,8 @@
[InlineData(null, null)]
public async Task FluentDialog_Alignment(DialogAlignment? alignment, string? expectedPosition)
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand Down Expand Up @@ -86,6 +90,8 @@
[InlineData("", (DialogAlignment)999)]
public async Task FluentDialog_Drawer(string expectedContains, DialogAlignment alignment)
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand Down Expand Up @@ -113,6 +119,8 @@
[InlineData(DialogState.Closing, "beforetoggle", "open", "any-new")]
public async Task FluentDialog_Toggle(DialogState state, string eventType, string oldState, string newState)
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();
var toggleArgs = new DialogToggleEventArgs()
Expand Down Expand Up @@ -156,6 +164,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_OpenClose()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions()
{
Expand All @@ -179,6 +189,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_ActionToClose()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand All @@ -205,6 +217,8 @@
[ClassData(typeof(Data.ShortcutData))]
public async Task FluentDialog_ShortcutToClose(Data.ShortcutDataItem item)
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = item.RenderOptions ?? new Templates.DialogRenderOptions();

Expand Down Expand Up @@ -244,6 +258,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_ShortcutInvalid()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions()
{
Expand Down Expand Up @@ -274,6 +290,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_WithInstance()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand All @@ -294,6 +312,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_ComponentRule()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand All @@ -313,6 +333,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_ProviderRequired()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();
DialogProvider.Instance.UpdateId(null);
Expand Down Expand Up @@ -409,6 +431,8 @@
[InlineData("type=\"modal\"", false)]
public async Task FluentDialog_Modal(string expectedContains, bool? modal)
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand All @@ -431,6 +455,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_InverseActions()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand Down Expand Up @@ -475,6 +501,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_PreventDismissOnEscape_Default_DoesNotCallJs()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var preventEscapeSetup = JSInterop.SetupVoid("Microsoft.FluentUI.Blazor.Components.Dialog.SetPreventEscapeClose", _ => true);
var renderOptions = new Templates.DialogRenderOptions();
Expand All @@ -495,6 +523,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_PreventDismissOnEscape_True_CallsJs()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var preventEscapeSetup = JSInterop.SetupVoid("Microsoft.FluentUI.Blazor.Components.Dialog.SetPreventEscapeClose", _ => true);
var renderOptions = new Templates.DialogRenderOptions();
Expand All @@ -518,6 +548,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_PreventDismissOnEscape_False_DoesNotCallJs()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var preventEscapeSetup = JSInterop.SetupVoid("Microsoft.FluentUI.Blazor.Components.Dialog.SetPreventEscapeClose", _ => true);
var renderOptions = new Templates.DialogRenderOptions();
Expand All @@ -540,6 +572,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_PreventDismissOnEscape_TrueThenFalse_OnlyFirstDialogCallsJs()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var preventEscapeSetup = JSInterop.SetupVoid("Microsoft.FluentUI.Blazor.Components.Dialog.SetPreventEscapeClose", _ => true);
var firstRenderOptions = new Templates.DialogRenderOptions() { AutoClose = true };
Expand Down Expand Up @@ -595,6 +629,8 @@
[InlineData("full", DialogSize.Full)]
public async Task FluentDialog_Size(string? expected, DialogSize? size)
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand Down Expand Up @@ -626,6 +662,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDialog_MarginPadding()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand Down
14 changes: 13 additions & 1 deletion tests/Core/Components/Dialog/FluentDrawerTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDrawer_Render()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand All @@ -50,6 +52,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDrawer_Options()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand All @@ -72,6 +76,8 @@
[InlineData("position=\"end\"", DialogAlignment.End)]
public async Task FluentDrawer_Position(string expectedContains, DialogAlignment alignment)
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand Down Expand Up @@ -111,7 +117,7 @@
});

// Don't wait for the dialog to be closed
await Task.CompletedTask;
await Task.CompletedTask.WaitAsync(Xunit.TestContext.Current.CancellationToken);

// Assert
var dialog = DialogProvider.Find("fluent-drawer");
Expand All @@ -132,6 +138,8 @@
[InlineData("type=\"non-modal\"", false)]
public async Task FluentDrawer_Modal(string expectedContains, bool? modal)
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand All @@ -154,6 +162,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentDrawer_InverseActions()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand Down Expand Up @@ -187,6 +197,8 @@
[InlineData("full", DialogSize.Full)]
public async Task FluentDrawer_Size(string? expected, DialogSize? size)
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var renderOptions = new Templates.DialogRenderOptions();

Expand Down
24 changes: 23 additions & 1 deletion tests/Core/Components/Dialog/FluentMessageBoxTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
var dialogTask = DialogService.ShowSuccessAsync("My message");

// Don't wait for the dialog to be closed
await Task.CompletedTask;
await Task.CompletedTask.WaitAsync(Xunit.TestContext.Current.CancellationToken);

// Assert
DialogProvider.Verify();
Expand All @@ -41,6 +41,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentMessageBox_SuccessCustomized()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Act
var dialogTask = DialogService.ShowSuccessAsync("My message", "My title", "OK");

Expand All @@ -54,6 +56,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentMessageBox_Info()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Act
var dialogTask = DialogService.ShowInfoAsync("My message");

Expand All @@ -67,6 +71,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentMessageBox_InfoCustomized()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Act
var dialogTask = DialogService.ShowInfoAsync("My message", "My title", "OK");

Expand All @@ -80,6 +86,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentMessageBox_Warning()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Act
var dialogTask = DialogService.ShowWarningAsync("My message");

Expand All @@ -93,6 +101,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentMessageBox_WarningCustomized()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Act
var dialogTask = DialogService.ShowWarningAsync("My message", "My title", "OK");

Expand All @@ -106,6 +116,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentMessageBox_Error()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Act
var dialogTask = DialogService.ShowErrorAsync("My message");

Expand All @@ -119,6 +131,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentMessageBox_ErrorCustomized()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Act
var dialogTask = DialogService.ShowErrorAsync("My message", "My title", "OK");

Expand All @@ -132,6 +146,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentMessageBox_Confirmation()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Act
var dialogTask = DialogService.ShowConfirmationAsync("My message");

Expand All @@ -145,6 +161,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentMessageBox_ConfirmationCustomized()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Act
var dialogTask = DialogService.ShowConfirmationAsync("My message", "My title", "Yes", "No");

Expand All @@ -160,6 +178,8 @@
[InlineData("N", true)]
public async Task ShowConfirmationAsync_ShortcutPressed_ReturnsExpectedResult(string shortcut, bool expectedCancelled)
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Arrange
var dialogTask = DialogService.ShowConfirmationAsync("My message");

Expand All @@ -174,6 +194,8 @@
[Fact(Timeout = TEST_TIMEOUT)]
public async Task FluentMessageBox_EmptyOptions()
{
Xunit.TestContext.Current.CancellationToken.ThrowIfCancellationRequested();

// Act
var dialogTask = DialogService.ShowMessageBoxAsync(new());

Expand Down
Loading
Loading