Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Method for MockSpi class that allows reading of the entire buffer for testing purposes #300

Open
MMMMMNG opened this issue Oct 6, 2023 · 0 comments

Comments

@MMMMMNG
Copy link
Contributor

MMMMMNG commented Oct 6, 2023

THIS IS ISSUE #300! 馃ぉ馃コ馃コ馃コ馃巶

Congrats pi4j people!

Consider this quote:
grafik
I think the same can be said for libraries like pi4j. So I think this calls for a celebration! 馃嵕馃嵑馃嵒
Also I think the quote would've been funnier if the creator of JavaScript was the one associated with it haha

...but anywho, I digress.

public class MockSpi extends SpiBase implements Spi {

I would love a method like MockSpi.readEntireMockBuffer() that could be used during testing to get all the bytes that were written to the mock object by calls to write() or transfer() and weren't yet consumed by calls to read() or transfer().

I tried to use a while loop and the read() method that returns -1 if the buffer is empty:
https://github.com/Pi4J/pi4j-v2/blob/8d8f1574f926dfd2961356cf015dcbd58e50664e/plugins/pi4j-plugin-mock/src/main/java/com/pi4j/plugin/mock/provider/spi/MockSpi.java#L145C1-L156C6

But I realised pretty quickly that this would cause a problem when the actual data was -1 (that's maybe also worth investigating).

In any case, It has been a pleasure to write Issue #300 for this awsm project!

Cheers
-MNG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant