protected async Task DiskEncryptionSet_List_Execute(string methodName, string location = null) { EnsureClientsInitialized(DefaultLocation); DiskRPLocation = location ?? DiskRPLocation; // Data var rgName1 = Recording.GenerateAssetName(TestPrefix); var rgName2 = Recording.GenerateAssetName(TestPrefix); var desName1 = Recording.GenerateAssetName(DiskNamePrefix); var desName2 = Recording.GenerateAssetName(DiskNamePrefix); DiskEncryptionSet des1 = GenerateDefaultDiskEncryptionSet(DiskRPLocation); DiskEncryptionSet des2 = GenerateDefaultDiskEncryptionSet(DiskRPLocation); // ********** // SETUP // ********** // Create resource groups await ResourceGroupsOperations.CreateOrUpdateAsync(rgName1, new ResourceGroup(DiskRPLocation)); await ResourceGroupsOperations.CreateOrUpdateAsync(rgName2, new ResourceGroup(DiskRPLocation)); // Put 4 diskEncryptionSets, 2 in each resource group await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartCreateOrUpdateAsync(rgName1, desName1, des1)); await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartCreateOrUpdateAsync(rgName1, desName2, des2)); await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartCreateOrUpdateAsync(rgName2, desName1, des1)); await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartCreateOrUpdateAsync(rgName2, desName2, des2)); // ********** // TEST // ********** // List diskEncryptionSets under resource group //IPage<DiskEncryptionSet> dessOut = await DiskEncryptionSetsClient.ListByResourceGroupAsync(rgName1).ToEnumerableAsync(); var dessOut = await DiskEncryptionSetsOperations.ListByResourceGroupAsync(rgName1).ToEnumerableAsync(); Assert.AreEqual(2, dessOut.Count()); //Assert.Null(dessOut.NextPageLink); dessOut = await DiskEncryptionSetsOperations.ListByResourceGroupAsync(rgName2).ToEnumerableAsync(); Assert.AreEqual(2, dessOut.Count()); //Assert.Null(dessOut.NextPageLink); // List diskEncryptionSets under subscription dessOut = await DiskEncryptionSetsOperations.ListAsync().ToEnumerableAsync(); Assert.True(dessOut.Count() >= 4); //if (dessOut.NextPageLink != null) //{ // dessOut = await DiskEncryptionSetsClient.ListNext(dessOut.NextPageLink); // Assert.True(dessOut.Any()); //} // Delete diskEncryptionSets await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartDeleteAsync(rgName1, desName1)); await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartDeleteAsync(rgName1, desName2)); await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartDeleteAsync(rgName2, desName1)); await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartDeleteAsync(rgName2, desName2)); }
protected async Task DiskEncryptionSet_CRUD_Execute(string methodName, string location = null) { EnsureClientsInitialized(DefaultLocation); DiskRPLocation = location ?? DiskRPLocation; // Data var rgName = Recording.GenerateAssetName(TestPrefix); var desName = Recording.GenerateAssetName(DiskNamePrefix); DiskEncryptionSet des = GenerateDefaultDiskEncryptionSet(DiskRPLocation); await ResourceGroupsOperations.CreateOrUpdateAsync(rgName, new ResourceGroup(DiskRPLocation)); // Put DiskEncryptionSet DiskEncryptionSet desOut = await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartCreateOrUpdateAsync(rgName, desName, des)); Validate(des, desOut, desName); // Get DiskEncryptionSet desOut = await DiskEncryptionSetsOperations.GetAsync(rgName, desName); Validate(des, desOut, desName); // Patch DiskEncryptionSet const string tagKey = "tageKey"; var updateDes = new DiskEncryptionSetUpdate(); updateDes.Tags = new Dictionary <string, string>() { { tagKey, "tagvalue" } }; desOut = await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartUpdateAsync(rgName, desName, updateDes)); Validate(des, desOut, desName); Assert.AreEqual(1, desOut.Tags.Count); // Delete DiskEncryptionSet await WaitForCompletionAsync(await DiskEncryptionSetsOperations.StartDeleteAsync(rgName, desName)); try { // Ensure it was really deleted await DiskEncryptionSetsOperations.GetAsync(rgName, desName); Assert.False(true); } catch (Exception ex) { Assert.NotNull(ex); //Assert.AreEqual(HttpStatusCode.NotFound, ex.Response.StatusCode); } }