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

[QUERY] How to mock GetArmDeployments #30587

Closed
amsoedal opened this issue Aug 18, 2022 · 6 comments · Fixed by #37927
Closed

[QUERY] How to mock GetArmDeployments #30587

amsoedal opened this issue Aug 18, 2022 · 6 comments · Fixed by #37927
Assignees
Labels
ARM Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@amsoedal
Copy link

Library name and version

Azure.ResourceManager.Resources 1.1.0

Query/Question

We're deploying an arm template using the Azure.ResourceManager packages, like so:

ResourceGroupResource resourceGroup = armClient.GetResourceGroupResource(resourceGroupId);
await resourceGroup.GetArmDeployments().CreateOrUpdateAsync(WaitUntil.Completed, CommonConstants.DeploymentName, content);

However, we're running into issues with unit testing this code, as GetArmDeployments() is a static method which cannot be mocked. Is there any guidance or documentation on how to work around this? I found a similar question here: #28861, and I'm wondering if there's a factory we need to use.

Environment

Windows 10 .NET 6.0
Visual Studio 17.3.0

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 18, 2022
@azure-sdk azure-sdk added ARM Mgmt This issue is related to a management-plane library. needs-team-triage Workflow: This issue needs the team to triage. labels Aug 18, 2022
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 18, 2022
@m-redding m-redding added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-team-triage Workflow: This issue needs the team to triage. labels Aug 18, 2022
@m-redding m-redding added the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Aug 19, 2022
@xboxeer
Copy link

xboxeer commented Aug 26, 2022

Mock of current version of mgmt. SDK is still in development phase, I'd suggest that instead of trying to mock extension method, a better way is put this extension method in a none-static method of your class than mock that none-static method

@adstep
Copy link

adstep commented Feb 3, 2023

Are there any updates on mocking the mgmt. SDK?

@Yao725
Copy link
Member

Yao725 commented Feb 21, 2023

Sorry for the delayed response, we already have an internal discussion about mocking extension methods and now I'm working on it.

@Yao725 Yao725 assigned Yao725 and unassigned xboxeer Feb 21, 2023
@jnlycklama
Copy link
Member

+1 to this issue. Would love to be able to mock out these static methods for Azure.ResourceManager.* packages. Is there any update on this @Yao725 ?

@amsoedal
Copy link
Author

Hi @Yao725, has this update been released?

@ArcturusZhang
Copy link
Member

ArcturusZhang commented Aug 4, 2023

Hey sorry for the delay of response. This feature is actively tracking here: Azure/autorest.csharp#3493
and there are a few betas we are going to release for this feature working in this PR: #37927

@ArcturusZhang ArcturusZhang assigned ArcturusZhang and unassigned Yao725 Aug 4, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ARM Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants