[QUERY] How to mock GetArmDeployments
See original GitHub issueLibrary 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: https://github.com/Azure/azure-sdk-for-net/issues/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
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
ResourceGroupResource Class (Azure.ResourceManager. ...
Initializes a new instance of the ResourceGroupResource class for mocking. ... Queries policy events for the resources under the resource group.
Read more >ResourcesManagementGroupM...
Mocking. Assembly: Azure.ResourceManager.Resources.dll. Package: Azure.ResourceManager. ... ArmDeploymentCollection GetArmDeployments ();
Read more >Mock Azure Function HttpTrigger and Setup Query String
You can create a new instance of QueryCollection (read this) and setup the mock. var mockDict = new Dictionary<string, StringValues> { { "key1", ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry for the delayed response, we already have an internal discussion about mocking extension methods and now I’m working on it.
+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 ?