RunicTestContextMenus class

Namespace Runic.Application.Testing in Runic.Application.Testing 0.23.0

public sealed class RunicTestContextMenus

Scripted context menus for IWindowPlatformServices.ShowContextMenuAsync in tests: each menu takes the next queued choice and is recorded.

Remarks

Queue the item the user chooses, by its command id, with RunicTestContextMenus.EnqueueChoice. A menu shown with an empty queue is dismissed. Choosing an item the menu does not have, or one that is disabled or in a disabled submenu, throws InvalidOperationException from the call, since the user could not choose it. Menus are checked with the rules of the real ones. The type is safe to use from any thread.

Properties

Calls

public IReadOnlyList<RunicContextMenuCall> Calls { get; }

The menus shown so far, oldest first.

UnavailableReason

public PlatformUnavailableReason? UnavailableReason { get; set; }

When set, every menu reports Unavailable with this reason, as a window without native context menus does.

Methods

EnqueueChoice

public void EnqueueChoice(string commandId, string? commandParameter = null)

Queues the item the user chooses in the next menu.

Parameters

commandId

The item's DesktopMenuItem.CommandId.

commandParameter

The item's DesktopMenuItem.CommandParameter when several items share the command id; null matches the first.

EnqueueDismissed

public void EnqueueDismissed()

Queues a dismissal of the next menu.