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
33 changes: 33 additions & 0 deletions src/Controls/tests/Core.UnitTests/Menu/MenuFlyoutSubItemTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Windows.Input;
using Microsoft.Maui.Handlers;
using Xunit;

Expand All @@ -10,6 +11,38 @@ namespace Microsoft.Maui.Controls.Core.UnitTests.Menu
public class MenuFlyoutSubItemTests :
MenuTestBase<MenuFlyoutSubItem, IMenuElement, MenuFlyoutItem, MenuFlyoutSubItemHandlerUpdate>
{
[Fact]
public void StartsEnabled()
{
MenuBarItem menuBarItem = new MenuBarItem();
Assert.True(menuBarItem.IsEnabled);
}

[Fact]
public void DisableWorks()
{
MenuBarItem menuBarItem = new MenuBarItem();
menuBarItem.IsEnabled = false;
Assert.False(menuBarItem.IsEnabled);
}

[Fact]
public void CommandPropertyChangesEnabled()
{
MenuFlyoutItem menuBarItem = new MenuFlyoutItem();

bool canExecute = true;
var command = new Command((p) => { }, (p) => p != null && (bool)p);
menuBarItem.CommandParameter = true;
menuBarItem.Command = command;

Assert.True(menuBarItem.IsEnabled);
menuBarItem.CommandParameter = false;
Assert.False(menuBarItem.IsEnabled);
menuBarItem.CommandParameter = true;
Assert.True(menuBarItem.IsEnabled);
}

protected override int GetIndex(MenuFlyoutSubItemHandlerUpdate handlerUpdate) =>
handlerUpdate.Index;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Maui.Platform;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls;

namespace Microsoft.Maui.Handlers
{
Expand Down
1 change: 1 addition & 0 deletions src/Core/src/Handlers/MenuBarItem/MenuBarItemHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public partial class MenuBarItemHandler : IMenuBarItemHandler
{
#if WINDOWS
[nameof(IMenuBarItem.Text)] = MapText,
[nameof(IMenuBarItem.IsEnabled)] = MapIsEnabled,
#endif
};

Expand Down