dotnet / dotnet/wpf

make MouseDevice mockable

Open
#5,743 4 comments 3 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

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((InputManager)t.Invoke(null)).Object;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.