public async Task TestTearDown() { DatabaseAccount account = await DatabaseAccountCollection.GetIfExistsAsync(_databaseAccountName); if (account != null) { await account.DeleteAsync(WaitUntil.Completed); } }
public async Task TestTearDown() { DatabaseAccount account = await DatabaseAccountCollection.GetIfExistsAsync(_databaseAccountName); if (account != null) { await account.Delete().WaitForCompletionResponseAsync(); } }
public async Task TestTearDown() { if (await DatabaseAccountCollection.ExistsAsync(_databaseAccountName)) { var id = DatabaseAccountCollection.Id; id = DatabaseAccountResource.CreateResourceIdentifier(id.SubscriptionId, id.ResourceGroupName, _databaseAccountName); DatabaseAccountResource account = this.ArmClient.GetDatabaseAccountResource(id); await account.DeleteAsync(WaitUntil.Completed); } }
public async Task DatabaseAccountDeleteTest() { var account = await CreateDatabaseAccount(Recording.GenerateAssetName("dbaccount-"), DatabaseAccountKind.MongoDB); await account.DeleteAsync(WaitUntil.Completed); List <DatabaseAccount> accounts = await DatabaseAccountCollection.GetAllAsync().ToEnumerableAsync(); Assert.IsNotNull(accounts); Assert.False(accounts.Any(a => a.Id == account.Id)); }
public async Task DatabaseAccountListByResourceGroupTest() { var account = await CreateDatabaseAccount(Recording.GenerateAssetName("dbaccount-"), DatabaseAccountKind.MongoDB); var accounts = await DatabaseAccountCollection.GetAllAsync().ToEnumerableAsync(); Assert.IsNotEmpty(accounts); Assert.That(accounts, Has.Count.EqualTo(1)); VerifyCosmosDBAccount(account, accounts[0]); }
public async Task DatabaseAccountCreateAndUpdateTest() { var account = await CreateDatabaseAccount(Recording.GenerateAssetName("dbaccount-"), DatabaseAccountKind.MongoDB); bool ifExists = await DatabaseAccountCollection.ExistsAsync(_databaseAccountName); Assert.AreEqual(true, ifExists); DatabaseAccount account2 = await DatabaseAccountCollection.GetAsync(_databaseAccountName); VerifyCosmosDBAccount(account, account2); var updateOptions = new PatchableDatabaseAccountData() { IsVirtualNetworkFilterEnabled = false, EnableAutomaticFailover = true, DisableKeyBasedMetadataWriteAccess = true, }; updateOptions.Tags.Add("key3", "value3"); updateOptions.Tags.Add("key4", "value4"); await account2.UpdateAsync(WaitUntil.Completed, updateOptions); var failoverPolicyList = new List <FailoverPolicy> { new FailoverPolicy() { LocationName = AzureLocation.WestUS, FailoverPriority = 0 } }; FailoverPolicies failoverPolicies = new FailoverPolicies(failoverPolicyList); await account2.FailoverPriorityChangeAsync(WaitUntil.Completed, new FailoverPolicies(failoverPolicyList)); DatabaseAccount account3 = await DatabaseAccountCollection.GetAsync(_databaseAccountName); VerifyCosmosDBAccount(account3, updateOptions); VerifyFailoverPolicies(failoverPolicyList, account3.Data.FailoverPolicies); }
// TODO: more tests after fixing the code generation issue protected async Task <DatabaseAccount> CreateRestorableDatabaseAccount(string name) { var locations = new List <DatabaseAccountLocation>() { new DatabaseAccountLocation(id: null, locationName: AzureLocation.WestUS, documentEndpoint: null, provisioningState: null, failoverPriority: null, isZoneRedundant: false) }; var createOptions = new DatabaseAccountCreateUpdateOptions(AzureLocation.WestUS, locations) { Kind = DatabaseAccountKind.GlobalDocumentDB, ConsistencyPolicy = new ConsistencyPolicy(DefaultConsistencyLevel.BoundedStaleness, MaxStalenessPrefix, MaxIntervalInSeconds), IpRules = { new IpAddressOrRange("23.43.231.120") }, IsVirtualNetworkFilterEnabled = true, EnableAutomaticFailover = false, ConnectorOffer = ConnectorOffer.Small, DisableKeyBasedMetadataWriteAccess = false, BackupPolicy = new ContinuousModeBackupPolicy(), }; _databaseAccountName = name; var accountLro = await DatabaseAccountCollection.CreateOrUpdateAsync(true, _databaseAccountName, createOptions); return(accountLro.Value); }