public async Task Exists() { ResourceProviderResource provider = await(await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false)).GetResourceProviders().GetAsync("Microsoft.Compute"); Assert.IsTrue(await provider.GetFeatures().ExistsAsync("AHUB")); Assert.IsFalse(await provider.GetFeatures().ExistsAsync("DoesNotExist")); }
public async Task Get() { ResourceProviderResource provider = await(await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false)).GetResourceProviders().GetAsync("Microsoft.Compute"); FeatureResource feature = await provider.GetFeatures().GetAsync("AHUB"); Assert.IsNotNull(feature); Assert.IsNotNull(feature.Data.Id); Assert.AreEqual("Microsoft.Compute/AHUB", feature.Data.Name); Assert.IsNotNull(feature.Data.Properties); Assert.IsNotNull(feature.Data.ResourceType); var ex = Assert.ThrowsAsync <RequestFailedException>(async() => _ = await provider.GetFeatures().GetAsync("DoesNotExist")); Assert.AreEqual(404, ex.Status); }
public async Task List() { ResourceProviderResource provider = await(await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false)).GetResourceProviders().GetAsync("Microsoft.Compute"); FeatureResource testFeature = null; await foreach (var feature in provider.GetFeatures().GetAllAsync()) { testFeature = feature; break; } Assert.IsNotNull(testFeature); Assert.IsNotNull(testFeature.Data.Id); Assert.IsNotNull(testFeature.Data.Name); Assert.IsNotNull(testFeature.Data.Properties); Assert.IsNotNull(testFeature.Data.ResourceType); }
public async Task RegisterAndUnregister() { //testing both register and unregister in the same test to avoid feature creep in our test subscription ResourceProviderResource provider = await(await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false)).GetResourceProviders().GetAsync("Microsoft.Compute"); FeatureResource feature = await provider.GetFeatures().GetAsync("AHUB"); FeatureResource afterRegister = await feature.RegisterAsync(); Assert.AreEqual(feature.Data.Id, afterRegister.Data.Id); Assert.AreEqual(feature.Data.Name, afterRegister.Data.Name); Assert.AreEqual("Pending", afterRegister.Data.Properties.State); Assert.AreEqual(feature.Data.ResourceType, afterRegister.Data.ResourceType); FeatureResource afterUnRegister = await feature.UnregisterAsync(); Assert.AreEqual(feature.Data.Id, afterUnRegister.Data.Id); Assert.AreEqual(feature.Data.Name, afterUnRegister.Data.Name); Assert.AreEqual("Unregistering", afterUnRegister.Data.Properties.State); Assert.AreEqual(feature.Data.ResourceType, afterUnRegister.Data.ResourceType); }
public async Task Get() { SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync(); ResourceProviderResource provider = await subscription.GetResourceProviders().GetAsync("Microsoft.Compute"); FeatureResource featureFromCollection = await GetFirst(provider.GetFeatures().GetAllAsync()); FeatureResource feature = await featureFromCollection.GetAsync(); Assert.AreEqual(featureFromCollection.Data.Id, feature.Data.Id); Assert.AreEqual(featureFromCollection.Data.Name, feature.Data.Name); Assert.AreEqual(featureFromCollection.Data.Properties.State, feature.Data.Properties.State); Assert.AreEqual(featureFromCollection.Data.ResourceType, feature.Data.ResourceType); ResourceIdentifier invalidId = new ResourceIdentifier(feature.Data.Id.ToString() + "x"); var ex = Assert.ThrowsAsync <RequestFailedException>(async() => _ = await Client.GetFeatureResource(invalidId).GetAsync()); Assert.AreEqual(404, ex.Status); }