-
Notifications
You must be signed in to change notification settings - Fork 492
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature request] Make DeviceClient extensible #1791
Comments
While I get the thought process behind this, if you depend on something as part of your business logic you still want to ensure that it gets called correctly. Today, there is no such way other than having an Azure IoT Hub instance around with pre-configured devices; then we are no longer talking about unit testing. |
Maybe having an |
That would be fine for me as well, happy to add the interface instead of removing |
Adding an interface is not going to be feasible in this case. However, we do think that removing the sealed from the clients is an acceptable solution. We will accept your pending PR request. If this is acceptable, can we close this issue? |
It is for me, I think. Thank you! Just out of curiosity, why is an interface not possible? |
Adding an interface means, whenever we add something new, it will break everyone who is implementing the interface. We always try to ship code that is not a breaking change for consumers. |
I think that would be fair but I also see your point. |
Specifically our factory methods to create a client would need to change type. We have strict guidelines not to change behavior in the client in ways that would break customers, because every tends to get cranky when their application doesn't build or crashes in new and exciting ways after updating to a new SDK. FWIW, the SDK is not designed or a built a way we very much like. In many ways we are stuck with decisions from the past. However, we'll be looking at a big client redesign to start fresh to solve a lot of these problems (like unit testable clients, more control over the pipeline, diagnostics, etc.). The Azure SDK team started this effort across all of Azure a few moons ago, and we're getting more and more of our SDKs on board. If you are curious, you can read about the guidelines here: https://azure.github.io/azure-sdk/dotnet_introduction.html. Thanks for finding a way to make our current client better. We appreciate it. :) |
Thanks for sharing and I'm happy to help! |
@tomkerkhove - I will be abandoning your PR. Here is the PR which has no build errors - https://github.com/Azure/azure-iot-sdk-csharp/pulls |
Ok for me! |
Just following up - Is there an ETA for a new version? |
We just released the new version with these changes - https://github.com/Azure/azure-iot-sdk-csharp/releases/tag/2021-03-18 |
Hello, thanks for working on this issue, but how is this supposed to be mockable now when the only constructor of Edit: Oh I missed that this request is only about |
We have made mocking very easy in all the Service Clients if you want to check it out - We have released a version of our clients that is mockable now - https://github.com/Azure/azure-iot-sdk-csharp/releases/tag/preview_2021-6-8 |
Awesome, thanks a lot! |
Hello. I am still having problems mocking the Could it be because the only constructor is private, and the existing static methods to create an instance, are using internal components (like the Additionally, if I try to setup method invocation on the mock (e.g.: I am using the 1.37.2 version. I guess it should already support mocking and there is not much difference for the latest). Does anyone know how to create a mock for this class? |
@PS99999 it looks like we added support for mocking the service clients, but not the device client. We'll add it to our backlog and see if we can't get that done. I probably won't be able to promise delivering it anytime soon, likely not before the end of this year, unfortunately. |
Thank you @drwill-ms for looking into it. |
@drwill-ms i have also the problem to mock the I am using the 1.39.0 version. Thank you. |
Is your feature request related to a problem? Please describe.
Make DeviceClient extensible so that we can build upon it, mock it, etc.
Describe the solution you'd like
I'm happy to open a PR to remove the
sealed
keyword on the class so that we can extend it.Describe alternatives you've considered
N/A
Additional context
Relates to #61 & #110 which blocks us from writing tests as well.
Thank you for helping make this project even better!
The text was updated successfully, but these errors were encountered: