public async Task CreateGetUpdateDeleteCluster() { //create a cluster _resourceGroup = await CreateResourceGroupAsync(); string clusterName = Recording.GenerateAssetName("cluster"); EventHubClusterCollection clusterCollection = _resourceGroup.GetEventHubClusters(); EventHubClusterData parameter = new EventHubClusterData(Location.EastUS2); EventHubCluster cluster = (await clusterCollection.CreateOrUpdateAsync(clusterName, parameter)).Value; Assert.NotNull(cluster); Assert.AreEqual(cluster.Data.Name, clusterName); //get the cluster cluster = await clusterCollection.GetAsync(clusterName); Assert.NotNull(cluster); Assert.AreEqual(cluster.Data.Name, clusterName); //get the namespace under cluster IReadOnlyList <SubResource> namspaceIds = (await cluster.GetNamespacesAsync()).Value; //update the cluster cluster.Data.Tags.Add("key", "value"); cluster = (await cluster.UpdateAsync(cluster.Data)).Value; Assert.AreEqual(cluster.Data.Tags["key"], "value"); //delete the cluster await cluster.DeleteAsync(); Assert.IsFalse(await clusterCollection.CheckIfExistsAsync(clusterName)); }
public async Task CreateGetUpdateDeleteCluster() { //create a cluster _resourceGroup = await CreateResourceGroupAsync(); string clusterName = Recording.GenerateAssetName("cluster"); EventHubClusterCollection clusterCollection = _resourceGroup.GetEventHubClusters(); EventHubClusterData parameter = new EventHubClusterData(AzureLocation.EastUS2); EventHubCluster cluster = (await clusterCollection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, parameter)).Value; Assert.NotNull(cluster); Assert.AreEqual(cluster.Data.Name, clusterName); //get the cluster cluster = await clusterCollection.GetAsync(clusterName); Assert.NotNull(cluster); Assert.AreEqual(cluster.Data.Name, clusterName); //get the namespace under cluster SubResource subResource = null; await foreach (var namespaceId in cluster.GetNamespacesAsync()) { subResource = namespaceId; break; } Assert.NotNull(subResource); //update the cluster cluster.Data.Tags.Add("key", "value"); cluster = (await cluster.UpdateAsync(WaitUntil.Completed, cluster.Data)).Value; Assert.AreEqual(cluster.Data.Tags["key"], "value"); //delete the cluster await cluster.DeleteAsync(WaitUntil.Completed); Assert.IsFalse(await clusterCollection.ExistsAsync(clusterName)); }