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.3k stars 4.66k forks source link

[QUERY] Details on IJsonModel<ManagedDiskData>.Create #46328

Open everest146 opened 1 day ago

everest146 commented 1 day ago

Library name and version

Azure.ResourceManager.Compute 1.4.0

Query/Question

I'm working on unit tests for a C# script that operates on managed disks, so I need to create some dummy disks and fill them with fake data for testing. The documentation for how to do this has been sparse. The way I have been trying to do this is by creating mock ManagedDiskResource objects, and using the IJsonModel.Create method to turn a json string of the fake data into a ManagedDiskData object that I can add to the mock ManagedDiskResource object. However, when I run the tests, IJsonModel.Create successfully executes, and I can retrieve the data with IJsonModel.Write, but when I try to retrieve the data through normal getter methods, it's not there! The data must be stored in the ManagedDiskData object somewhere, but Create() isn't filling out the object's fields with the data as I need it to. I may be formatting the json object incorrectly, but I could not know since I can't find any guidelines for how to format it; I also couldn't find the implementation for the Create method. I've attached the mock class file for reference with what I've described above included. I would like some guidelines for how to correctly format the json (assuming I'm formating incorrectly) and some advice on the intended what to create dummy ManagedDisksResource objects (assuming I'm overcomplicating it). One last note -- I did look for a factory class to create the ManagedDiskResource objects, but there didn't appear to be one. Thanks. MockManagedDiskResource.txt

Environment

Windows 10, .NET v8, Visual Studio 2022 17.10.6

jsquire commented 1 day ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.