Skip to content

Commit

Permalink
Make the protected methods in AbstractHidClient protected internal be…
Browse files Browse the repository at this point in the history
…cause it makes unit testing those methods much easier, without any crazy HidSharp mocking or asynchronous timing problems.
  • Loading branch information
Aldaviva committed Apr 9, 2023
1 parent ae318e8 commit 8e2ffe8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions HidClient/AbstractHidClient.cs
Expand Up @@ -106,7 +106,7 @@ public abstract class AbstractHidClient: IHidClient {
/// <summary>
/// Called when connected to a device after it was previously disconnected. When invoked, <see cref="IsConnected"/> will be <see langword="true"/>.
/// </summary>
protected virtual void OnConnect() { }
protected internal virtual void OnConnect() { }

private async Task HidReadLoop() {
CancellationToken cancellationToken = _cancellationTokenSource!.Token;
Expand Down Expand Up @@ -134,7 +134,7 @@ public abstract class AbstractHidClient: IHidClient {
/// Callback method that is invoked when HID bytes are read from the device.
/// </summary>
/// <param name="readBuffer">Bytes that were read from the device, matching the <c>HID Data</c> field in USBPcap.</param>
protected abstract void OnHidRead(byte[] readBuffer);
protected internal abstract void OnHidRead(byte[] readBuffer);

private void ReattachToDevice(object? sender = null, EventArgs? e = null) {
bool disconnected = false;
Expand Down
2 changes: 1 addition & 1 deletion HidClient/HidClient.csproj
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<Authors>Ben Hutchison</Authors>
<Company>Ben Hutchison</Company>
<PackageId>HidClient</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion Tests/FakeHidClient.cs
Expand Up @@ -13,7 +13,7 @@ public class FakeHidClient: AbstractHidClient {
protected override int VendorId { get; } = 0x077d;
protected override int ProductId { get; } = 0x0410;

protected override void OnHidRead(byte[] readBuffer) {
protected internal override void OnHidRead(byte[] readBuffer) {
HidRead?.Invoke(this, readBuffer);
}

Expand Down

0 comments on commit 8e2ffe8

Please sign in to comment.