A Swiss Army knife for developers.
C# blazorcross-platformcsharpdesktopdesktop-appdesktop-applicationdeveloper-toolsextensiblefluentfluent-designlinuxmacosmicasyntax-highlightingtypescriptwindowswindows-10windows-11winui
Updated a test and added some documentation
Etienne Baudoux4c93addbbb6f
diff --git a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.csindex f4398fa83..4d778fac6 100644--- a/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs+++ b/src/app/dev/DevToys.Api/Tool/GUI/Components/IUISetting.cs@@ -187,6 +187,9 @@ public static partial class GUI/// <param name="settingDefinition">The definition of the setting to associate with this <see cref="IUISetting"/>.</param>/// <param name="onToggled">(optional) A method to invoke when the setting value changes.</param>/// <returns>The updated <see cref="IUISetting"/> instance.</returns>+ /// <remarks>+ /// The binding with the setting is going in both directions. When the setting is set, the switch is updated. When the switch is toggled, the setting is updated.+ /// </remarks>public static IUISetting Handle(this IUISetting element,ISettingsProvider settingsProvider,@@ -212,6 +215,9 @@ public static partial class GUI/// <param name="settingDefinition">The definition of the setting to associate with this <see cref="IUISetting"/>.</param>/// <param name="onToggled">(optional) A method to invoke when the setting value changes.</param>/// <returns>The updated <see cref="IUISetting"/> instance.</returns>+ /// <remarks>+ /// The binding with the setting is going in both directions. When the setting is set, the switch is updated. When the switch is toggled, the setting is updated.+ /// </remarks>public static IUISetting Handle(this IUISetting element,ISettingsProvider settingsProvider,@@ -243,6 +249,9 @@ public static partial class GUI/// <param name="stateDescriptionWhenOff">The <see cref="IUISetting.StateDescription"/> to use when the option is Off.</param>/// <param name="onToggled">(optional) A method to invoke when the setting value changed.</param>/// <returns>The updated <see cref="IUISetting"/> instance.</returns>+ /// <remarks>+ /// The binding with the setting is going in both directions. When the setting is set, the switch is updated. When the switch is toggled, the setting is updated.+ /// </remarks>public static IUISetting Handle(this IUISetting element,ISettingsProvider settingsProvider,@@ -272,6 +281,9 @@ public static partial class GUI/// <param name="stateDescriptionWhenOff">The <see cref="IUISetting.StateDescription"/> to use when the option is Off.</param>/// <param name="onToggled">(optional) A method to invoke when the setting value changed.</param>/// <returns>The updated <see cref="IUISetting"/> instance.</returns>+ /// <remarks>+ /// The binding with the setting is going in both directions. When the setting is set, the switch is updated. When the switch is toggled, the setting is updated.+ /// </remarks>public static IUISetting Handle(this IUISetting element,ISettingsProvider settingsProvider,@@ -304,6 +316,9 @@ public static partial class GUI/// <param name="onOptionSelected">(optional) A method to invoke when the setting value changed.</param>/// <param name="dropDownListItems">(optional) A list of items to be displayed in the drop down list. <see cref="IUIDropDownListItem.Value"/> should be of type <typeparamref name="T"/>.</param>/// <returns>The updated <see cref="IUISetting"/> instance.</returns>+ /// <remarks>+ /// The binding with the setting is going in both directions. When the setting is changed, the drop down list is updated. When the drop down list is changed, the setting is updated.+ /// </remarks>public static IUISetting Handle<T>(this IUISetting element,ISettingsProvider settingsProvider,@@ -333,6 +348,9 @@ public static partial class GUI/// <param name="onOptionSelected">(optional) A method to invoke when the setting value changed.</param>/// <param name="dropDownListItems">(optional) A list of items to be displayed in the drop down list. <see cref="IUIDropDownListItem.Value"/> should be of type <typeparamref name="T"/>.</param>/// <returns>The updated <see cref="IUISetting"/> instance.</returns>+ /// <remarks>+ /// The binding with the setting is going in both directions. When the setting is changed, the drop down list is updated. When the drop down list is changed, the setting is updated.+ /// </remarks>public static IUISetting Handle<T>(this IUISetting element,ISettingsProvider settingsProvider,diff --git a/src/app/tests/DevToys.UnitTests/Blazor/Core/Extensions/IJSRuntimeExtensionsTests.cs b/src/app/tests/DevToys.UnitTests/Blazor/Core/Extensions/IJSRuntimeExtensionsTests.csindex 90b0c1989..b12f08e25 100644--- a/src/app/tests/DevToys.UnitTests/Blazor/Core/Extensions/IJSRuntimeExtensionsTests.cs+++ b/src/app/tests/DevToys.UnitTests/Blazor/Core/Extensions/IJSRuntimeExtensionsTests.cs@@ -48,20 +48,4 @@ public class IJSRuntimeExtensionsTestsruntimeMock.Verify();}-- [Fact]- public async Task InvokeVoidAsyncWithErrorHandling_ThrowsForUnhandledExceptions()- {- var runtimeMock = new Mock<IJSRuntime>(MockBehavior.Strict);-- runtimeMock.Setup(x => x.InvokeAsync<IJSVoidResult>("myMethod", It.IsAny<object[]>()))- .Throws(new InvalidOperationException("mhh that is odd")).Verifiable();-- IJSRuntime runtime = runtimeMock.Object;-- InvalidOperationException ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await runtime.InvokeVoidWithErrorHandlingAsync("myMethod", 42, "blub"));-- ex.Message.Should().Be("mhh that is odd");- runtimeMock.Verify();- }}