Skip to content

make MouseDevice mockable #5743

@trivalik

Description

@trivalik

The class https://github.com/dotnet/wpf/blob/main/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/MouseDevice.cs does not allow right now to derive from it. This prevent any Mocking library to work.

As far as I can see is it enough to change the access modifier from
internal abstract MouseButtonState GetButtonStateFromSystem(MouseButton mouseButton);

Code to test with Moq:

var t = typeof(InputManager).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[0], null);
var mouseDevice = new Moq.Mock<MouseDevice>((InputManager)t.Invoke(null)).Object;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions