Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.25k stars 4.6k forks source link

[QUERY] Mocking with ArmClient and CostManagementExportCollection #45697

Open jeremysimmons opened 3 weeks ago

jeremysimmons commented 3 weeks ago

Library name and version

Azure.ResourceManager.CostManagement 1.0.1

Query/Question

It is quite difficult to mock functionality related to the Cost Management api, specifically around the CostManagementExportResource.

Once you've instantiated the

According to the design guidelines, https://azure.github.io/azure-sdk/dotnet_introduction.html,

DO use instance methods instead of extension methods when defined in the same assembly. The instance methods are simpler to mock.

I'm assuming this is because ArmClient is in Azure.ResourceManager and CostManagementExtensions is in Azure.ResourceManager.CostManagement.

I would much rather have a CostManagementClient that takes an ArmClient as a parameter than have the current debacle.

Additionally this guidance seems to be missing completely.

(https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-mocking-factory-builder) DO provide factory or builder for constructing model graphs returned from virtual service methods.

Maybe I'm missing it, but I wanted a simple/easy way for my business class to call. If I'm missing something obvious, please let me know.

var exports = armClient.GetCostManagementExports(scope).
exports.CreateOrUpdateAsync

Environment

dotnet core 6 VS 2022 v17.9.6

github-actions[bot] commented 3 weeks ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @anthony-c-martin @calecarter @cemheren @j5lim @majastrz.