public async Task CanCreateResourceGroup() { string groupName = Recording.GenerateAssetName("csmrg"); var result = await ResourceGroupsOperations.CreateOrUpdateAsync(groupName, new ResourceGroup(DefaultLocation) { Tags = { { "department", "finance" }, { "tagname", "tagvalue" } }, }); var listResult = await ResourceGroupsOperations.ListAsync().ToEnumerableAsync(); var listedGroup = listResult.FirstOrDefault((g) => string.Equals(g.Name, groupName, StringComparison.Ordinal)); Assert.NotNull(listedGroup); Assert.AreEqual("finance", listedGroup.Tags["department"]); Assert.AreEqual("tagvalue", listedGroup.Tags["tagname"]); Assert.True(Utilities.LocationsAreEqual(DefaultLocation, listedGroup.Location), string.Format("Expected location '{0}' did not match actual location '{1}'", DefaultLocation, listedGroup.Location)); var gottenGroup = (await ResourceGroupsOperations.GetAsync(groupName)).Value; Assert.NotNull(gottenGroup); Assert.AreEqual(groupName, gottenGroup.Name); Assert.True(Utilities.LocationsAreEqual(DefaultLocation, gottenGroup.Location), string.Format("Expected location '{0}' did not match actual location '{1}'", DefaultLocation, gottenGroup.Location)); }
public async Task DeleteResourceGroupRemovesGroup() { var resourceGroupName = Recording.GenerateAssetName("csmrg"); var createResult = await ResourceGroupsOperations.CreateOrUpdateAsync(resourceGroupName, new ResourceGroup(DefaultLocation)); var getResult = await ResourceGroupsOperations.GetAsync(resourceGroupName); var rawDeleteResult = await ResourceGroupsOperations.StartDeleteAsync(resourceGroupName); var deleteResult = (await WaitForCompletionAsync(rawDeleteResult)).Value; var listResult = await ResourceGroupsOperations.ListAsync(null).ToEnumerableAsync(); Assert.AreEqual(200, deleteResult.Status); foreach (var rg in listResult) { if (rg.Name == resourceGroupName) { Assert.AreNotEqual("Deleting", rg.Properties.ProvisioningState); } } }