我正在构建一个利用 Microsoft Azure 的应用程序,并且我正在使用 Microsoft Azure .NET API 调用来管理我的基础架构。我想进入测试阶段,我很好奇是否有办法强制调用使其他提供的虚假参数失败。
例如,我有以下启动 VM 的代码片段。有没有办法让这个调用在给定正确的参数时自动失败?
using (ComputeManagementClient client = new ComputeManagementClient(new CertificateCloudCredentials(c_subscriptionId, MyCert)))
{
var status = client.VirtualMachines.Start(serviceName, deploymentName, vmName);
if (status.Status == OperationStatus.Failed)
{
throw new MachineCreationException(status.Error.Code, null);
}
}
提前致谢!