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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] Make DPS Queries testable #3439

Open
Gamecock opened this issue Mar 5, 2024 · 2 comments · May be fixed by #3461
Open

[feature request] Make DPS Queries testable #3439

Gamecock opened this issue Mar 5, 2024 · 2 comments · May be fixed by #3461
Labels
enhancement New feature or request.

Comments

@Gamecock
Copy link

Gamecock commented Mar 5, 2024

https://github.com/Azure/azure-iot-sdk-csharp/blob/main/provisioning/service/src/Config/QueryResult.cs

The QueryResponseClass needs to be modifiable to allow testing of applications that query the DPS.

I'm happy to do the work, just looking for guidance on how you would like to proceed.

@Gamecock Gamecock added the enhancement New feature or request. label Mar 5, 2024
@timtay-microsoft
Copy link
Member

timtay-microsoft commented Mar 11, 2024

Just to clarify, are you asking for this class to be mockable in the context of unit tests in your project that uses this SDK?

If so, I'd recommend adding an IQuery interface for the provisioningServiceClient.CreateEnrollmentGroupQuery and provisioningServiceClient.CreateEnrollmentGroupRegistrationStateQuery and provisioningServiceClient.CreateIndividualEnrollmentQuery to return instead of the concrete class Query they currently return. The interface will need to match the Query so it would look something like

public interface IQuery : IDisposable
{
    public int PageSize { get; set; }
    public string ContinuationToken { get; set; }

    public bool HasNext();
    public async Task<QueryResult> NextAsync(string continuationToken);
    public async Task<QueryResult> NextAsync();
}

Once that is checked into this repo, you should be able to make your provisioning service client return a mocked IQuery object that you have full control over.

@Gamecock
Copy link
Author

Thanks, that what I was looking for.

@Gamecock Gamecock linked a pull request Jun 14, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants