Library or service name.
Azure.ResourceManager.Storage
Is your feature request related to a problem? Please describe.
[Fact]
public async Task Solve()
{
var operations = Substitute.For<StorageAccountsOperations>();
operations
.StartCreateAsync("rg", Arg.Any<string>(), Arg.Any<StorageAccountCreateParameters>())
.Returns(new StorageAccountsCreateOperation(null, null, null, null)); // <-- [CS1729] 'StorageAccountsCreateOperation' does not contain a constructor that takes 4 arguments
var storage = Substitute.For<StorageManagementClient>();
storage.StorageAccounts.Returns(operations);
var operation = await _storage.StorageAccounts.StartCreateAsync(_rg, $"sa{DateTime.Now.Ticks}",
new StorageAccountCreateParameters(new Sku(SkuName.StandardLRS), Kind.Storage, _location));
await operation.WaitForCompletionAsync();
}
Would be really happy to turn my integration tests into unit tests but that's not impossible while these constructor(s) are internal.
Thank you for your feedback. Tagging and routing to the team member best able to assist.
The same applies for example on the ResourceGroupsOperations that is returned by ResourcesManagementClient.
public virtual async Task<ResourceGroupsDeleteOperation> StartDeleteAsync(string resourceGroupName, CancellationToken cancellationToken = default)
The method is virtual so I _can_ override it with a mock, but then the return type ResourceGroupsDeleteOperation only has an internal constructor so I'm not able instantiate it or create a derived type.
Would be great if the method would use a the base class or interface for its return type.
I think it's the same issue as described here https://github.com/Azure/azure-sdk-for-net/issues/15639.
It would also follow the guidelines described here https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-mocking
Sure, but mine was first 馃槢 Thanks for the heads-up on the mocking guidelines, wouldn't have found it myself but still doesn't seem to be in place for the aforementioned operations.
Most helpful comment
Sure, but mine was first 馃槢 Thanks for the heads-up on the mocking guidelines, wouldn't have found it myself but still doesn't seem to be in place for the aforementioned operations.