From 25a2c0c85352c5da1b5ab7c34de18b916999bef3 Mon Sep 17 00:00:00 2001 From: Ismail Hassani Date: Sun, 17 Dec 2023 06:45:31 +0100 Subject: [PATCH 1/5] Update initializersLoader.webview.js (#1141) "as any" is a TypeScript directive and generates unhandled exceptions in browsers --- src/Core/wwwroot/js/initializersLoader.webview.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Core/wwwroot/js/initializersLoader.webview.js b/src/Core/wwwroot/js/initializersLoader.webview.js index c8984db056..a9793696da 100644 --- a/src/Core/wwwroot/js/initializersLoader.webview.js +++ b/src/Core/wwwroot/js/initializersLoader.webview.js @@ -18,7 +18,7 @@ window.fetch = originalFetch; } - const response = await originalFetch(resource as any, config); + const response = await originalFetch(resource, config); return response; } } @@ -38,4 +38,4 @@ function getAppName() { return appName; } -setupLoader(); \ No newline at end of file +setupLoader(); From f2842ccc2ead924b331c06b7b040a2d2224ec802 Mon Sep 17 00:00:00 2001 From: Denis Voituron Date: Sun, 17 Dec 2023 11:54:24 +0100 Subject: [PATCH 2/5] Search icons on all sizes (#1142) --- Directory.Packages.props | 11 ++++++----- .../Components/Controls/PreviewCard.razor | 3 +++ .../Components/Controls/PreviewCard.razor.cs | 3 +++ .../Components/Controls/PreviewCard.razor.css | 7 +++++++ .../Components/Pages/IconExplorer.razor | 8 ++++---- .../Components/Pages/IconExplorer.razor.cs | 18 ++++++++++++++---- .../AssetExplorer/Models/IconSearchCriteria.cs | 2 +- 7 files changed, 38 insertions(+), 14 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index f755a7221f..8bf32035ba 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,7 +6,11 @@ 8.0.0 - + + + + + @@ -19,13 +23,10 @@ - - - - + diff --git a/examples/Demo/AssetExplorer/Components/Controls/PreviewCard.razor b/examples/Demo/AssetExplorer/Components/Controls/PreviewCard.razor index 59f21ce22e..0c0fd0036f 100644 --- a/examples/Demo/AssetExplorer/Components/Controls/PreviewCard.razor +++ b/examples/Demo/AssetExplorer/Components/Controls/PreviewCard.razor @@ -6,6 +6,9 @@ Title="Copy to clipboard" /> @if (Icon is not null) { + + @TopLeftLabel + - + Items="@AllAvailableSizes" + OptionText="@(i => i > 0 ? $"Size{i}" : "[All]")" /> @foreach (var item in IconsForCurrentPage) { - + } diff --git a/examples/Demo/AssetExplorer/Components/Pages/IconExplorer.razor.cs b/examples/Demo/AssetExplorer/Components/Pages/IconExplorer.razor.cs index 8e4b9ad663..10951d5301 100644 --- a/examples/Demo/AssetExplorer/Components/Pages/IconExplorer.razor.cs +++ b/examples/Demo/AssetExplorer/Components/Pages/IconExplorer.razor.cs @@ -50,10 +50,10 @@ private async Task StartNewSearchAsync() IconsFound = [ .. Icons.AllIcons - .Where(i => i.Variant == Criteria.Variant - && i.Size == Criteria.Size - && (string.IsNullOrWhiteSpace(Criteria.SearchTerm) ? true : i.Name.Contains(Criteria.SearchTerm, StringComparison.InvariantCultureIgnoreCase))) - .OrderBy(i => i.Name) + .Where(i => i.Variant == Criteria.Variant + && (Criteria.Size > 0 ? (int)i.Size == Criteria.Size : true) + && (string.IsNullOrWhiteSpace(Criteria.SearchTerm) ? true : i.Name.Contains(Criteria.SearchTerm, StringComparison.InvariantCultureIgnoreCase))) + .OrderBy(i => i.Name) , ]; @@ -66,4 +66,14 @@ private void HandleCurrentPageIndexChanged() { StateHasChanged(); } + + private IEnumerable AllAvailableSizes + { + get + { + var sizes = Enum.GetValues().Select(i => (int)i).ToList(); + var empty = new int[] { 0 }; + return empty.Concat(sizes); + } + } } diff --git a/examples/Demo/AssetExplorer/Models/IconSearchCriteria.cs b/examples/Demo/AssetExplorer/Models/IconSearchCriteria.cs index 5cc968dd40..aa7900b69a 100644 --- a/examples/Demo/AssetExplorer/Models/IconSearchCriteria.cs +++ b/examples/Demo/AssetExplorer/Models/IconSearchCriteria.cs @@ -6,6 +6,6 @@ internal class IconSearchCriteria { public string SearchTerm { get; set; } = string.Empty; public IconVariant Variant { get; set; } = IconVariant.Regular; - public IconSize Size { get; set; } = IconSize.Size24; + public int Size { get; set; } = 20; public Color Color { get; set; } = Color.Accent; } From 449bb990fce12ebdd714cd914a7bd75e2e6a68bb Mon Sep 17 00:00:00 2001 From: Denis Voituron Date: Sun, 17 Dec 2023 21:42:07 +0100 Subject: [PATCH 3/5] [List components] Each item must be instantiated (cannot be null). (#1144) * Add and check a notnull constraint * Add doc --- src/Core/Components/List/FluentAutocomplete.razor.cs | 2 +- src/Core/Components/List/FluentCombobox.razor.cs | 2 +- src/Core/Components/List/FluentListbox.razor.cs | 2 +- src/Core/Components/List/FluentSelect.razor.cs | 2 +- src/Core/Components/List/ListComponentBase.cs | 10 ++++++++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Core/Components/List/FluentAutocomplete.razor.cs b/src/Core/Components/List/FluentAutocomplete.razor.cs index 36714d6d29..cc2aead0c3 100644 --- a/src/Core/Components/List/FluentAutocomplete.razor.cs +++ b/src/Core/Components/List/FluentAutocomplete.razor.cs @@ -7,7 +7,7 @@ namespace Microsoft.FluentUI.AspNetCore.Components; [CascadingTypeParameter(nameof(TOption))] -public partial class FluentAutocomplete : ListComponentBase +public partial class FluentAutocomplete : ListComponentBase where TOption : notnull { public const string JAVASCRIPT_FILE = "./_content/Microsoft.FluentUI.AspNetCore.Components/Components/List/FluentAutocomplete.razor.js"; private string _valueText = string.Empty; diff --git a/src/Core/Components/List/FluentCombobox.razor.cs b/src/Core/Components/List/FluentCombobox.razor.cs index 6a1d52ea45..cfe15c6e66 100644 --- a/src/Core/Components/List/FluentCombobox.razor.cs +++ b/src/Core/Components/List/FluentCombobox.razor.cs @@ -3,7 +3,7 @@ namespace Microsoft.FluentUI.AspNetCore.Components; [CascadingTypeParameter(nameof(TOption))] -public partial class FluentCombobox : ListComponentBase +public partial class FluentCombobox : ListComponentBase where TOption : notnull { /// /// Gets or sets a value indicating whether the element auto completes. See diff --git a/src/Core/Components/List/FluentListbox.razor.cs b/src/Core/Components/List/FluentListbox.razor.cs index f1638d49ac..f02f83e921 100644 --- a/src/Core/Components/List/FluentListbox.razor.cs +++ b/src/Core/Components/List/FluentListbox.razor.cs @@ -4,7 +4,7 @@ namespace Microsoft.FluentUI.AspNetCore.Components; [CascadingTypeParameter(nameof(TOption))] -public partial class FluentListbox : ListComponentBase +public partial class FluentListbox : ListComponentBase where TOption : notnull { /// /// Gets or sets the maximum number of options that should be visible in the listbox scroll area. diff --git a/src/Core/Components/List/FluentSelect.razor.cs b/src/Core/Components/List/FluentSelect.razor.cs index 8e7161e9a6..a262010227 100644 --- a/src/Core/Components/List/FluentSelect.razor.cs +++ b/src/Core/Components/List/FluentSelect.razor.cs @@ -4,7 +4,7 @@ namespace Microsoft.FluentUI.AspNetCore.Components; [CascadingTypeParameter(nameof(TOption))] -public partial class FluentSelect : ListComponentBase +public partial class FluentSelect : ListComponentBase where TOption : notnull { /// protected virtual MarkupString InlineStyleValue => new InlineStyleBuilder() diff --git a/src/Core/Components/List/ListComponentBase.cs b/src/Core/Components/List/ListComponentBase.cs index 90b2fc3cdb..7f5dfe5a03 100644 --- a/src/Core/Components/List/ListComponentBase.cs +++ b/src/Core/Components/List/ListComponentBase.cs @@ -7,7 +7,7 @@ namespace Microsoft.FluentUI.AspNetCore.Components; /// Component that provides a list of options. /// /// -public abstract class ListComponentBase : FluentComponentBase +public abstract class ListComponentBase : FluentComponentBase where TOption : notnull { private bool _multiple = false; private List _selectedOptions = []; @@ -131,6 +131,7 @@ protected string? InternalValue /// /// Gets or sets the content source of all items to display in this list. + /// Each item must be instantiated (cannot be null). /// [Parameter] public virtual IEnumerable? Items { get; set; } @@ -425,8 +426,13 @@ protected virtual async Task RaiseChangedEventsAsync() builder.AddAttribute(4, "ChildContent", (RenderFragment)(content => { + if (item is null) + { + throw new NullReferenceException($"You cannot use a null element as an option in the {nameof(Items)} property."); + } + content.AddContent(5, GetOptionText(item)); - if (item!.GetType().IsGenericType && item.GetType().GetGenericTypeDefinition() == typeof(Option<>)) + if (item.GetType().IsGenericType && item.GetType().GetGenericTypeDefinition() == typeof(Option<>)) { Option? t = item as Option; if (t is not null) From f8aed5dc18c7a90b5cc21ddd21c69d966de15421 Mon Sep 17 00:00:00 2001 From: Denis Voituron Date: Mon, 18 Dec 2023 10:14:28 +0100 Subject: [PATCH 4/5] Fix Loading button with styles (#1146) Co-authored-by: Vincent Baaij --- src/Core/Components/Button/FluentButton.razor | 9 ++++----- src/Core/Components/Button/FluentButton.razor.cs | 3 +++ src/Core/Components/Button/FluentButton.razor.css | 8 ++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Core/Components/Button/FluentButton.razor b/src/Core/Components/Button/FluentButton.razor index 6b342a8c3b..263b31012c 100644 --- a/src/Core/Components/Button/FluentButton.razor +++ b/src/Core/Components/Button/FluentButton.razor @@ -7,10 +7,9 @@ } - -@if (Loading && IconStart == null && IconEnd == null) +@if (LoadingOverlay) { - + @_renderButton @@ -24,8 +23,8 @@ else protected void RenderButton(RenderTreeBuilder __builder) { Loading && IconStart == null && IconEnd == null; + /// /// Determines if the element should receive document focus on page load. /// diff --git a/src/Core/Components/Button/FluentButton.razor.css b/src/Core/Components/Button/FluentButton.razor.css index 10e4d91c0e..d5da0a1de0 100644 --- a/src/Core/Components/Button/FluentButton.razor.css +++ b/src/Core/Components/Button/FluentButton.razor.css @@ -1,12 +1,12 @@ .loading-button { - display: flex; - align-items: center; - width: fit-content; - justify-content: center; + position: relative; } .loading-button ::deep fluent-progress-ring { position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); width: 16px; height: 16px; cursor: not-allowed; From 940efee137768bd0d5bb771e6545dc13e13d13e4 Mon Sep 17 00:00:00 2001 From: Denis Voituron Date: Mon, 18 Dec 2023 10:15:44 +0100 Subject: [PATCH 5/5] [FluentIcon] Add Unit Tests (#1140) * Add Icons Tests * Fix UnitTest * Add Exception Test * Add Missing Test --- tests/Core/Extensions/SampleIcons.cs | 2 +- ...FluentIcon_ButtonStart.verified.razor.html | 5 + ...Tests.FluentIcon_Color.verified.razor.html | 4 + ...FluentIcon_CustomColor.verified.razor.html | 4 + ...sts.FluentIcon_Default.verified.razor.html | 4 + ...entIcon_Icon_FromImage.verified.razor.html | 4 + ...uentIcon_Icon_ToMarkup.verified.razor.html | 6 + ...con_Icon_ToMarkupColor.verified.razor.html | 6 + ...Icon_Icon_ToMarkupSize.verified.razor.html | 6 + ...Icon_Icon_WithColorRed.verified.razor.html | 4 + ...orRed_OverridenByColor.verified.razor.html | 4 + ..._Icon_WithColorSuccess.verified.razor.html | 4 + ...s.FluentIcon_SlotTitle.verified.razor.html | 5 + ...nTests.FluentIcon_Type.verified.razor.html | 4 + ....FluentIcon_Type_Color.verified.razor.html | 4 + ...Tests.FluentIcon_Width.verified.razor.html | 4 + tests/Core/Icons/FluentIconTests.razor | 206 ++++++++++++++++++ tests/Core/_ToDo/Icons/FluentIconTests.cs | 34 --- 18 files changed, 275 insertions(+), 35 deletions(-) create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_ButtonStart.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Color.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_CustomColor.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Default.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Icon_FromImage.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkup.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkupColor.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkupSize.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorRed.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorRed_OverridenByColor.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorSuccess.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_SlotTitle.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Type.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Type_Color.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.FluentIcon_Width.verified.razor.html create mode 100644 tests/Core/Icons/FluentIconTests.razor delete mode 100644 tests/Core/_ToDo/Icons/FluentIconTests.cs diff --git a/tests/Core/Extensions/SampleIcons.cs b/tests/Core/Extensions/SampleIcons.cs index aa484d2b9c..249c6dcd6d 100644 --- a/tests/Core/Extensions/SampleIcons.cs +++ b/tests/Core/Extensions/SampleIcons.cs @@ -8,7 +8,7 @@ public static class SampleIcons public static readonly Icon PresenceAvailable = new Samples.PresenceAvailable(); - private class Samples + internal class Samples { internal class Info : Icon { public Info() : base("Info", IconVariant.Filled, IconSize.Size24, "") { } } diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_ButtonStart.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_ButtonStart.verified.razor.html new file mode 100644 index 0000000000..c0bbf4cbc8 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_ButtonStart.verified.razor.html @@ -0,0 +1,5 @@ + + + My Button \ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Color.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Color.verified.razor.html new file mode 100644 index 0000000000..f430837c41 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Color.verified.razor.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_CustomColor.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_CustomColor.verified.razor.html new file mode 100644 index 0000000000..360a14d960 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_CustomColor.verified.razor.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Default.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Default.verified.razor.html new file mode 100644 index 0000000000..cd899d4eaa --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Default.verified.razor.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_FromImage.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_FromImage.verified.razor.html new file mode 100644 index 0000000000..f318d091d6 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_FromImage.verified.razor.html @@ -0,0 +1,4 @@ + +
+ +
\ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkup.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkup.verified.razor.html new file mode 100644 index 0000000000..5cf76e7aab --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkup.verified.razor.html @@ -0,0 +1,6 @@ + +
+ +
\ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkupColor.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkupColor.verified.razor.html new file mode 100644 index 0000000000..d3b8496d01 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkupColor.verified.razor.html @@ -0,0 +1,6 @@ + +
+ +
\ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkupSize.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkupSize.verified.razor.html new file mode 100644 index 0000000000..c356107c20 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_ToMarkupSize.verified.razor.html @@ -0,0 +1,6 @@ + +
+ +
\ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorRed.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorRed.verified.razor.html new file mode 100644 index 0000000000..03e5d9cbb9 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorRed.verified.razor.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorRed_OverridenByColor.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorRed_OverridenByColor.verified.razor.html new file mode 100644 index 0000000000..f430837c41 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorRed_OverridenByColor.verified.razor.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorSuccess.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorSuccess.verified.razor.html new file mode 100644 index 0000000000..4535566e81 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Icon_WithColorSuccess.verified.razor.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_SlotTitle.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_SlotTitle.verified.razor.html new file mode 100644 index 0000000000..8cc9c30672 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_SlotTitle.verified.razor.html @@ -0,0 +1,5 @@ + + \ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Type.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Type.verified.razor.html new file mode 100644 index 0000000000..cd899d4eaa --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Type.verified.razor.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Type_Color.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Type_Color.verified.razor.html new file mode 100644 index 0000000000..f430837c41 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Type_Color.verified.razor.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.FluentIcon_Width.verified.razor.html b/tests/Core/Icons/FluentIconTests.FluentIcon_Width.verified.razor.html new file mode 100644 index 0000000000..325acc8c48 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.FluentIcon_Width.verified.razor.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/tests/Core/Icons/FluentIconTests.razor b/tests/Core/Icons/FluentIconTests.razor new file mode 100644 index 0000000000..345f4d0cf8 --- /dev/null +++ b/tests/Core/Icons/FluentIconTests.razor @@ -0,0 +1,206 @@ +@using Microsoft.FluentUI.AspNetCore.Components.Tests.Extensions +@using Xunit; +@inherits TestContext +@code +{ + [Fact] + public void FluentIcon_Default() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_Type() + { + // Arrange && Act + var cut = Render(@); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_SlotTitle() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_Color() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_Type_Color() + { + // Arrange && Act + var cut = Render(@); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_CustomColor() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_CustomColor_RequiresColorAttribute() + { + Assert.Throws(() => + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@); + + // Assert an exception because Color=Color.Custom is required + }); + } + + [Fact] + public void FluentIcon_Width() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_OnClick() + { + var isClicked = false; + + // Arrange + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@); + + // Act + cut.Find("svg").Click(); + + // Assert + Assert.True(isClicked); + } + + [Fact] + public void FluentIcon_ButtonStart() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@My Button); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_Icon_FromImage() + { + // Arrange && Act + var cut = Render(@); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_Icon_FromEmptyImage() + { + // Arrange && Act + var icon = new IconFromImage(); + + // Assert + Assert.Empty(icon.Content); + + } + [Fact] + public void FluentIcon_Icon_WithColorRed() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_Icon_WithColorRed_OverridenByColor() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_Icon_WithColorSuccess() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_Icon_ToMarkup() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@
@icon.ToMarkup()
); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_Icon_ToMarkupSize() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@
@icon.ToMarkup(size: "100px")
); + + // Assert + cut.Verify(); + } + + [Fact] + public void FluentIcon_Icon_ToMarkupColor() + { + // Arrange && Act + var icon = new SampleIcons.Samples.Info(); + var cut = Render(@
@icon.ToMarkup(color: "blue")
); + + // Assert + cut.Verify(); + } +} \ No newline at end of file diff --git a/tests/Core/_ToDo/Icons/FluentIconTests.cs b/tests/Core/_ToDo/Icons/FluentIconTests.cs deleted file mode 100644 index 5f7938617d..0000000000 --- a/tests/Core/_ToDo/Icons/FluentIconTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Bunit; -using Microsoft.AspNetCore.Components.Web; -using Xunit; - -namespace Microsoft.FluentUI.AspNetCore.Components.Tests.Icons; - -public class FluentIconTests : TestBase -{ - [Fact(Skip = "Need to figure out how to do this test")] - public void FluentIcon_Default() - { - //Arrange - string slot = default!; - string title = default!; - Color? color = default!; - string customColor = default!; - string width = default!; - Icon value = default!; - Action onClick = _ => { }; - var cut = TestContext.RenderComponent>(parameters => parameters - .Add(p => p.Slot, slot) - .Add(p => p.Title, title) - .Add(p => p.Color, color) - .Add(p => p.CustomColor, customColor) - .Add(p => p.Width, width) - .Add(p => p.Value, value) - .Add(p => p.OnClick, onClick) - ); - //Act - - //Assert - cut.Verify(); - } -} \ No newline at end of file