public void TestManagedInstanceLongTermRetentionResourceGroupBasedCrud() { // MANUAL TEST INSTRUCTIONS // PlayBack Mode: // Make sure information below matches what is gets recorded in Session Records // Record Mode: // Create a server and database and fill in the appropriate information below // Set the weekly retention on the database so that the first backup gets picked up // Wait about 18 hours until it gets properly copied and you see the backup when run get backups // OR // Use existing instance/database that already has LTR backups // string locationName = "southeastasia"; string resourceGroupName = "sdk-test-rg"; string managedInstanceName = "sdk-test-mi"; string databaseName = "test"; using (SqlManagementTestContext context = new SqlManagementTestContext(this)) { SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>(); //ManagedDatabase database = sqlClient.ManagedDatabases.Get(resourceGroupName, managedInstanceName, databaseName); // Get the backups under the location, server, and database. Assert there is at least one backup for each call. // IPage <ManagedInstanceLongTermRetentionBackup> backups = sqlClient.LongTermRetentionManagedInstanceBackups.ListByResourceGroupLocation(resourceGroupName, locationName); Assert.True(backups.Count() >= 1); backups = sqlClient.LongTermRetentionManagedInstanceBackups.ListByResourceGroupInstance(resourceGroupName, locationName, managedInstanceName); Assert.True(backups.Count() >= 1); backups = sqlClient.LongTermRetentionManagedInstanceBackups.ListByResourceGroupDatabase(resourceGroupName, locationName, managedInstanceName, databaseName); Assert.True(backups.Count() >= 1); // Get a specific backup using the previous call // ManagedInstanceLongTermRetentionBackup backup = sqlClient.LongTermRetentionManagedInstanceBackups.GetByResourceGroup(resourceGroupName, locationName, managedInstanceName, databaseName, backups.First().Name); Assert.NotNull(backup); // Restore the backup // ManagedDatabase restoredDatabase = sqlClient.ManagedDatabases.CreateOrUpdate( resourceGroupName, managedInstanceName, databaseName: SqlManagementTestUtilities.GenerateName(), parameters: new ManagedDatabase { Location = locationName, CreateMode = CreateMode.RestoreLongTermRetentionBackup, LongTermRetentionBackupResourceId = backup.Id }); // Delete the backup. // sqlClient.LongTermRetentionManagedInstanceBackups.DeleteByResourceGroupWithHttpMessagesAsync(resourceGroupName, locationName, managedInstanceName, databaseName, backup.Name); } }
public void TestLongTermRetentionV2ResourceGroupBasedCrud() { // MANUAL TEST INSTRUCTIONS // PlayBack Mode: // Remove skip flag // Record Mode: // Create a server and database and fill in the appropriate information below // Set the weekly retention on the database so that the first backup gets picked up // Wait about 18 hours until it gets properly copied and you see the backup when run get backups // string locationName = "brazilsouth"; string resourceGroupName = "brrg"; string serverName = "ltrtest3"; string databaseName = "mydb"; using (SqlManagementTestContext context = new SqlManagementTestContext(this)) { SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>(); Database database = sqlClient.Databases.Get(resourceGroupName, serverName, databaseName); // Get the backups under the location, server, and database. Assert there is at least one backup for each call. // IPage <LongTermRetentionBackup> backups = sqlClient.LongTermRetentionBackups.ListByResourceGroupLocation(resourceGroupName, locationName); Assert.True(backups.Count() >= 1); backups = sqlClient.LongTermRetentionBackups.ListByResourceGroupServer(resourceGroupName, locationName, serverName); Assert.True(backups.Count() >= 1); backups = sqlClient.LongTermRetentionBackups.ListByResourceGroupDatabase(resourceGroupName, locationName, serverName, databaseName); Assert.True(backups.Count() >= 1); // Get a specific backup using the previous call // LongTermRetentionBackup backup = sqlClient.LongTermRetentionBackups.GetByResourceGroup(resourceGroupName, locationName, serverName, databaseName, backups.First().Name); Assert.NotNull(backup); // Restore the backup // Database restoredDatabase = sqlClient.Databases.CreateOrUpdate( resourceGroupName, serverName, databaseName: SqlManagementTestUtilities.GenerateName(), parameters: new Database { Location = locationName, CreateMode = CreateMode.RestoreLongTermRetentionBackup, LongTermRetentionBackupResourceId = backup.Id }); // Delete the backup. // sqlClient.LongTermRetentionBackups.DeleteByResourceGroupWithHttpMessagesAsync(resourceGroupName, locationName, serverName, databaseName, backup.Name); } }
public void CommunityGalleryImageVersion_GetAndList_Tests() { using (MockContext context = MockContext.Start(this.GetType())) { EnsureClientsInitialized(context); CommunityGalleryImageVersion communityGalleryImageVersionOut = m_CrpClient.CommunityGalleryImageVersions.Get(galleryAccessLocation, PublicGalleryName, GalleryImageName, GalleryImageVersionName); Trace.TraceInformation("Got the community gallery image name {0} which is shared to public.", GalleryImageVersionName); Assert.NotNull(communityGalleryImageVersionOut); ValidateCommunityGalleryImageVersion(communityGalleryImageVersionOut); IPage <CommunityGalleryImageVersion> communityGalleryImageVersionsList = m_CrpClient.CommunityGalleryImageVersions.List(galleryAccessLocation, PublicGalleryName, GalleryImageName); Trace.TraceInformation("Got the community gallery image versions which are shared to public."); int count = communityGalleryImageVersionsList.Count(); Assert.Equal(1, count); foreach (CommunityGalleryImageVersion galleryImageVersion in communityGalleryImageVersionsList) { if (galleryImageVersion.Name == GalleryImageVersionName) { ValidateCommunityGalleryImageVersion(galleryImageVersion); break; } } } }
public void ListWithoutResourceGroupTest() { using (var context = MockContext.Start(this.GetType())) { var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); IPage <RedisResource> listResponse = _client.Redis.ListBySubscription(); Assert.True(listResponse.Count() >= 1); bool found = false; foreach (RedisResource response in listResponse) { if (response.Id.Contains(fixture.RedisCacheName)) { found = true; Assert.Contains(fixture.RedisCacheName, response.Id); Assert.Equal(fixture.RedisCacheName, response.Name); Assert.Equal(ProvisioningState.Succeeded, response.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Basic, response.Sku.Name); Assert.Equal(SkuFamily.C, response.Sku.Family); Assert.Equal(0, response.Sku.Capacity); Assert.Contains(fixture.RedisCacheName, response.HostName); Assert.Equal(6379, response.Port); Assert.Equal(6380, response.SslPort); } } Assert.True(found, "Cache created by fixture is not found."); } }
public async Task <ICursor <T> > GetCursorAsync <T>(Guid signalId) { myCoreService = CoreService.GetInstance(); var signal = await myCoreService.GetOneByIdAsync(signalId); int sampleCount = (int)signal.NumberOfSamples; List <IPage <SEPayload> > listIPage = new List <IPage <SEPayload> >(); List <long> dimPage = new List <long>(); Byte[] pagingState = null; Cql cql = Cql.New("SELECT * FROM sepayload where parentid=?", signalId); IPage <SEPayload> ipagePartialList = (await mapper.FetchPageAsync <SEPayload>(cql.WithOptions(opt => opt.SetPageSize(pagesize).SetPagingState(pagingState)))); listIPage.Add(ipagePartialList); while (ipagePartialList.PagingState != null) { pagingState = ipagePartialList.PagingState; ipagePartialList = (await mapper.FetchPageAsync <SEPayload>(cql.WithOptions(opt => opt.SetPageSize(pagesize).SetPagingState(pagingState)))); if (ipagePartialList.Count() > 0) { listIPage.Add(ipagePartialList); } } long dimPageCount = listIPage.Count() - dimPage.Sum(); dimPage.Add(dimPageCount); Cursor <T> jdbccursor = new Cursor <T>(listIPage); return(jdbccursor); }
public void SharedGalleryImage_GetAndList_Tests() { using (MockContext context = MockContext.Start(this.GetType())) { EnsureClientsInitialized(context); SharedGalleryImage sharedGalleryImageOut = m_CrpClient.SharedGalleryImages.Get(galleryAccessLocation, GalleryUniqueName, GalleryImageName); Trace.TraceInformation("Got the shared gallery image {0} which is shared to current subscription.", GalleryImageName); Assert.NotNull(sharedGalleryImageOut); ValidateSharedGalleryImage(sharedGalleryImageOut); IPage <SharedGalleryImage> sharedGalleryImagesList = m_CrpClient.SharedGalleryImages.List(galleryAccessLocation, GalleryUniqueName, "tenant"); Trace.TraceInformation("Got the shared gallery images which are shared to tenant of current subscription."); int count = sharedGalleryImagesList.Count(); Assert.Equal(1, count); foreach (SharedGalleryImage galleryImage in sharedGalleryImagesList) { if (galleryImage.Name == GalleryImageName) { ValidateSharedGalleryImage(galleryImage); break; } } sharedGalleryImagesList = m_CrpClient.SharedGalleryImages.List(galleryAccessLocation, GalleryUniqueName); count = sharedGalleryImagesList.Count(); Assert.Equal(1, count); Trace.TraceInformation("Got the shared gallery {0} which is shared to current subscription.", GalleryUniqueName); ValidateSharedGalleryImage(sharedGalleryImagesList.First()); sharedGalleryImagesList = m_CrpClient.SharedGalleryImages.List(galleryAccessLocation, GalleryUniqueName, sharedTo: SharedToValues.Tenant); count = sharedGalleryImagesList.Count(); Assert.Equal(1, count); Trace.TraceInformation("Got the shared gallery {0} which is shared to current tenant.", GalleryUniqueName); ValidateSharedGalleryImage(sharedGalleryImagesList.First()); } }
public void SyncAgentCRUDTest() { string testPrefix = "syncagentcrudtest-"; using (SqlManagementTestContext context = new SqlManagementTestContext(this)) { ResourceGroup resourceGroup = context.CreateResourceGroup(); SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>(); Server server = context.CreateServer(resourceGroup); // Create database string dbName = SqlManagementTestUtilities.GenerateName(testPrefix); Database db = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, dbName, new Database() { Location = server.Location, }); Assert.NotNull(db); Assert.NotNull(db.Id); // Create sync agent string agentName = SqlManagementTestUtilities.GenerateName("syncagentcrudtest"); SyncAgent createAgent = sqlClient.SyncAgents.CreateOrUpdate(resourceGroup.Name, server.Name, agentName, new SyncAgent { SyncDatabaseId = db.Id }); Assert.NotNull(createAgent); // Get sync agent SyncAgent getAgent = sqlClient.SyncAgents.Get(resourceGroup.Name, server.Name, agentName); Assert.NotNull(getAgent); // List sync agent IPage <SyncAgent> listAgents = sqlClient.SyncAgents.ListByServer(resourceGroup.Name, server.Name); Assert.Equal(1, listAgents.Count()); Assert.Equal(agentName, listAgents.Single().Name); // Generate key SyncAgentKeyProperties agentKey = sqlClient.SyncAgents.GenerateKey(resourceGroup.Name, server.Name, agentName); Assert.NotNull(agentKey); Assert.NotNull(agentKey.SyncAgentKey); // Regenerate key SyncAgentKeyProperties agentKey2 = sqlClient.SyncAgents.GenerateKey(resourceGroup.Name, server.Name, agentName); Assert.NotNull(agentKey2); Assert.NotNull(agentKey2.SyncAgentKey); // Get linked databases IPage <SyncAgentLinkedDatabase> linkedDatabases = sqlClient.SyncAgents.ListLinkedDatabases(resourceGroup.Name, server.Name, agentName); Assert.NotNull(linkedDatabases); Assert.Equal(0, linkedDatabases.Count()); // Delete the sync agent sqlClient.SyncAgents.Delete(resourceGroup.Name, server.Name, agentName); } }
public void Gallery_CRUD_Tests() { using (MockContext context = MockContext.Start(this.GetType())) { EnsureClientsInitialized(context); string rgName = ComputeManagementTestUtilities.GenerateName(ResourceGroupPrefix); string rgName2 = rgName + "New"; m_ResourcesClient.ResourceGroups.CreateOrUpdate(rgName, new ResourceGroup { Location = galleryHomeLocation }); Trace.TraceInformation("Created the resource group: " + rgName); string galleryName = ComputeManagementTestUtilities.GenerateName(GalleryNamePrefix); Gallery galleryIn = GetTestInputGallery(); m_CrpClient.Galleries.CreateOrUpdate(rgName, galleryName, galleryIn); Trace.TraceInformation(string.Format("Created the gallery: {0} in resource group: {1}", galleryName, rgName)); Gallery galleryOut = m_CrpClient.Galleries.Get(rgName, galleryName); Trace.TraceInformation("Got the gallery."); Assert.NotNull(galleryOut); ValidateGallery(galleryIn, galleryOut); galleryIn.Description = "This is an updated description"; m_CrpClient.Galleries.CreateOrUpdate(rgName, galleryName, galleryIn); Trace.TraceInformation("Updated the gallery."); galleryOut = m_CrpClient.Galleries.Get(rgName, galleryName); ValidateGallery(galleryIn, galleryOut); Trace.TraceInformation("Listing galleries."); string galleryName2 = galleryName + "New"; m_ResourcesClient.ResourceGroups.CreateOrUpdate(rgName2, new ResourceGroup { Location = galleryHomeLocation }); Trace.TraceInformation("Created the resource group: " + rgName2); ComputeManagementTestUtilities.WaitSeconds(10); m_CrpClient.Galleries.CreateOrUpdate(rgName2, galleryName2, galleryIn); Trace.TraceInformation(string.Format("Created the gallery: {0} in resource group: {1}", galleryName2, rgName2)); IPage <Gallery> listGalleriesInRgResult = m_CrpClient.Galleries.ListByResourceGroup(rgName); Assert.Single(listGalleriesInRgResult); Assert.Null(listGalleriesInRgResult.NextPageLink); IPage <Gallery> listGalleriesInSubIdResult = m_CrpClient.Galleries.List(); // Below, >= instead of == is used because this subscription is shared in the group so other developers // might have created galleries in this subscription. Assert.True(listGalleriesInSubIdResult.Count() >= 2); Trace.TraceInformation("Deleting 2 galleries."); m_CrpClient.Galleries.Delete(rgName, galleryName); m_CrpClient.Galleries.Delete(rgName2, galleryName2); listGalleriesInRgResult = m_CrpClient.Galleries.ListByResourceGroup(rgName); Assert.Empty(listGalleriesInRgResult); // resource groups cleanup is taken cared by MockContext.Dispose() method. } }
public async Task ListSupportedCloudServiceSkusMaxResultsAsync() { using (MockContext context = StartMockContextAndInitializeClients(GetType())) { int maxresult = 5; IPage <SupportedSku> result = await BatchManagementClient.Location.ListSupportedCloudServiceSkusAsync(Location, maxresults : maxresult); int count = result.Count(); Assert.True(count == maxresult); } }
public void SharedGallery_GetAndList_Tests() { using (MockContext context = MockContext.Start(this.GetType())) { EnsureClientsInitialized(context); SharedGallery sharedGalleryOut = m_CrpClient.SharedGalleries.Get(galleryAccessLocation, GalleryUniqueName); Trace.TraceInformation("Got the shared gallery {0} which is shared to current subscription.", GalleryUniqueName); Assert.NotNull(sharedGalleryOut); ValidateSharedGallery(sharedGalleryOut); IPage <SharedGallery> sharedGalleriesList = m_CrpClient.SharedGalleries.List(galleryAccessLocation, "tenant"); Trace.TraceInformation("Got the shared galleries which are shared to tenant of current subscription."); int count = sharedGalleriesList.Count(); Assert.True(count > 0); foreach (SharedGallery gallery in sharedGalleriesList) { if (gallery.Name == GalleryUniqueName) { ValidateSharedGallery(gallery); break; } } sharedGalleriesList = m_CrpClient.SharedGalleries.List(galleryAccessLocation); count = sharedGalleriesList.Count(); Assert.True(count > 0); Trace.TraceInformation("Got the shared gallery {0} which is shared to current subscription.", GalleryUniqueName); foreach (SharedGallery gallery in sharedGalleriesList) { if (gallery.Name == GalleryUniqueName) { ValidateSharedGallery(gallery); break; } } } }
protected void RunTest(ISqlManagementClient client, string resourceGroupName, string serverName, string databaseName) { IPage <SensitivityLabel> sensitivityLabels = ListCurrentSensitivityLabels( client, resourceGroupName, serverName, databaseName); Assert.NotNull(sensitivityLabels); Assert.Empty(sensitivityLabels); sensitivityLabels = ListRecommendedSensitivityLabels(client, resourceGroupName, serverName, databaseName); Assert.NotNull(sensitivityLabels); Assert.NotEmpty(sensitivityLabels); int recommendedLabelsCount = sensitivityLabels.Count(); SensitivityLabel recommendedLabel = sensitivityLabels.First(); string columnName = recommendedLabel.Id.Split("/")[16]; SensitivityLabel newLabel = new SensitivityLabel( labelName: recommendedLabel.LabelName, labelId: recommendedLabel.LabelId, informationType: recommendedLabel.InformationType, informationTypeId: recommendedLabel.InformationTypeId); SensitivityLabel createdLabel = CreateOrUpdateSensitivityLabel(client, resourceGroupName, serverName, databaseName, s_SchemaName, s_TableName, columnName, newLabel); AssertEqual(recommendedLabel, createdLabel); createdLabel = GetSensitivityLabel(client, resourceGroupName, serverName, databaseName, s_SchemaName, s_TableName, columnName); AssertEqual(recommendedLabel, createdLabel); sensitivityLabels = ListRecommendedSensitivityLabels(client, resourceGroupName, serverName, databaseName); Assert.NotNull(sensitivityLabels); Assert.Equal(recommendedLabelsCount - 1, sensitivityLabels.Count()); DeleteSensitivityLabel(client, resourceGroupName, serverName, databaseName, s_SchemaName, s_TableName, columnName); sensitivityLabels = ListRecommendedSensitivityLabels( client, resourceGroupName, serverName, databaseName); Assert.NotNull(sensitivityLabels); Assert.Equal(recommendedLabelsCount, sensitivityLabels.Count()); }
private void VerifyCloudServiceRoleInstanceResponseMatchesExpected(IPage <RoleInstance> roleInstanceList, Dictionary <string, string> expectedRoleInstanceNameMappedWithSkuName) { Assert.NotNull(roleInstanceList); Assert.True(expectedRoleInstanceNameMappedWithSkuName.Count == roleInstanceList.Count(), "CloudService RoleInstances count should match"); foreach (RoleInstance roleInstance in roleInstanceList) { Assert.True(expectedRoleInstanceNameMappedWithSkuName.ContainsKey(roleInstance.Name), "Returned RoleInstance Name should be present in Expected RoleInstance Names"); Assert.True(expectedRoleInstanceNameMappedWithSkuName[roleInstance.Name] == roleInstance.Sku.Name, "RoleInstance Sku should match expected sku"); expectedRoleInstanceNameMappedWithSkuName.Remove(roleInstance.Name); } }
public void SupportTicketListTest() { using (var context = MockContext.Start(this.GetType())) { IPage <Models.SupportTicketDetails> supportTicketList = null; using (var client = context.GetServiceClient <MicrosoftSupportClient>()) { supportTicketList = client.SupportTickets.List(); Assert.True(supportTicketList.Count() > 0); } if (!string.IsNullOrWhiteSpace(supportTicketList.NextPageLink)) { using (var client = context.GetServiceClient <MicrosoftSupportClient>()) { supportTicketList = client.SupportTickets.ListNext(supportTicketList.NextPageLink); Assert.True(supportTicketList.Count() > 0); } } } }
private void ValidatePolicyStatesQueryResults(IPage <PolicyState> queryResults, bool expandPolicyEvaluationDetails = false) { Assert.NotNull(queryResults); var count = queryResults.Count(); Assert.True(count >= 0); if (count == 1000) { Assert.NotNull(queryResults.NextPageLink); } else { Assert.Null(queryResults.NextPageLink); } foreach (var policyState in queryResults) { Assert.NotNull(policyState); Assert.Null(policyState.Odataid); Assert.False(string.IsNullOrEmpty(policyState.Odatacontext)); Assert.True(policyState.Timestamp.HasValue); Assert.False(string.IsNullOrEmpty(policyState.ResourceId)); Assert.False(string.IsNullOrEmpty(policyState.PolicyAssignmentId)); Assert.False(string.IsNullOrEmpty(policyState.PolicyDefinitionId)); Assert.True(policyState.IsCompliant.HasValue); Assert.False(string.IsNullOrEmpty(policyState.SubscriptionId)); Assert.False(string.IsNullOrEmpty(policyState.PolicyDefinitionAction)); Assert.False(string.IsNullOrEmpty(policyState.ComplianceState)); Assert.NotNull(policyState.PolicyDefinitionGroupNames); Assert.NotEmpty(policyState.PolicyDefinitionGroupNames); if (expandPolicyEvaluationDetails && string.Equals(policyState.ComplianceState, "NonCompliant", StringComparison.OrdinalIgnoreCase)) { Assert.NotNull(policyState.PolicyEvaluationDetails); } else { Assert.Null(policyState.PolicyEvaluationDetails); } Assert.NotNull(policyState.PolicyDefinitionVersion); Assert.NotNull(policyState.PolicySetDefinitionVersion); Assert.NotNull(policyState.PolicyAssignmentVersion); Assert.NotNull(policyState.AdditionalProperties); Assert.False(policyState.AdditionalProperties.ContainsKey("policyDefinitionVersion")); Assert.False(policyState.AdditionalProperties.ContainsKey("policySetDefinitionVersion")); Assert.False(policyState.AdditionalProperties.ContainsKey("policyAssignmentVersion")); } }
private void SkipNObjects(out IPage <SupportTicketDetails> supportTicketPage, out IEnumerable <SupportTicketDetails> supportTickets) { var remainingSkip = this.MyInvocation.BoundParameters.ContainsKey("Skip") ? this.PagingParameters.Skip : 0; supportTicketPage = this.SupportClient.SupportTickets.List(filter: this.Filter); var actualSkipCount = Math.Min(remainingSkip, (uint)supportTicketPage.Count()); supportTickets = supportTicketPage.Skip((int)actualSkipCount); remainingSkip -= actualSkipCount; // Skip more while (remainingSkip > 0 && supportTicketPage != null && !string.IsNullOrWhiteSpace(supportTicketPage.NextPageLink)) { supportTicketPage = this.SupportClient.SupportTickets.ListNext(supportTicketPage.NextPageLink); actualSkipCount = Math.Min(remainingSkip, (uint)supportTicketPage.Count()); supportTickets = supportTicketPage.Skip((int)actualSkipCount); remainingSkip -= actualSkipCount; } }
public void TestLongTermRetentionV2Backups() { using (SqlManagementTestContext context = new SqlManagementTestContext(this)) { ResourceGroup resourceGroup = context.CreateResourceGroup(); Server server = context.CreateServer(resourceGroup); SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>(); Database database = sqlClient.Databases.CreateOrUpdate(resourceGroup.Name, server.Name, SqlManagementTestUtilities.GenerateName(), new Database { Location = server.Location }); // Get the backups under the server and database. Assert there are no backups returned. // Note: While we call ListByLocation, we can't guarantee there are no backups under that location for the subscription. // IPage <LongTermRetentionBackup> backups = sqlClient.LongTermRetentionBackups.ListByLocation(server.Location); backups = sqlClient.LongTermRetentionBackups.ListByServer(server.Location, server.Name); Assert.True(backups.Count() == 0); backups = sqlClient.LongTermRetentionBackups.ListByDatabase(server.Location, server.Name, database.Name); Assert.True(backups.Count() == 0); Assert.Throws(typeof(CloudException), () => sqlClient.LongTermRetentionBackups.Get(server.Location, server.Name, database.Name, "backup")); } }
public void ListDetectorsValidateResponse() { var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(@"{ 'value': [ { 'type': 'Microsoft.Batch/batchAccounts/detectors', 'id': '/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/detectors/poolsAndNodes', 'name': 'poolsAndNodes', 'properties': { 'value': 'ew0KICAibWV0YWRhdGEiOiB7DQogICAgIml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kIjogIjMyNjM1MDk0IiwNCiAgICAgICAgInBlc0lkIjogIjE1NjE0IiwNCiAgICAgICAgInR5cGVJZCI6ICJEaWFnbm9zdGljcy5Nb2RlbHNBbmRVdGlscy5BdHRyaWJ1dGVzLlN1cHBvcnRUb3BpYywgRGlhZ25vc3RpY3MuTW9kZWxzQW5kVXRpbHMsIFZlcnNpb249MS4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsIg0KICAgICAgfQ0KICAgIF0sDQogICAgImFuYWx5c2lzVHlwZXMiOiBudWxsLA0KICAgICJ0eXBlIjogIkFuYWx5c2lzIiwNCiAgICAic2NvcmUiOiAwLjANCiAgfSwNCiAgImRhdGFzZXQiOiBbXSwNCiAgInN0YXR1cyI6IHsNCiAgICAibWVzc2FnZSI6IG51bGwsDQogICAgInN0YXR1c0lkIjogNA0KICB9LA0KICAiZGF0YVByb3ZpZGVyc01ldGFkYXRhIjogbnVsbCwNCiAgInN1Z2dlc3RlZFV0dGVyYW5jZXMiOiBudWxsDQp9' } }, { 'type': 'Microsoft.Batch/batchAccounts/detectors', 'id': '/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/detectors/anotherDetector', 'name': 'otherDetector', 'properties': { 'value': 'ew0KICAibWV0YWRhdGEiOiB7DQogICAgImlkIjogInBvb2xzQW5kTm9kZXMiLA0KICAgICJuYW1lIjogIlBvb2xzIGFuZCBOb2RlcyIsDQogICAgImRlc2NyaXB0aW9uIjogbnVsbCwNCiAgICAiYXV0aG9yIjogIiIsDQogICAgImNhdGVnb3J5IjogbnVsbCwNCiAgICAic3VwcG9ydFRvcGljTGlzdCI6IFsNCiAgICAgIHsNCiAgICAgICAgImlkIjogIjMyNjM1MDc3IiwNCiAgICAgICAgInBlc0lkIjogIjE1NjE0IiwNCiAgICAgICAgInR5cGVJZCI6ICJEaWFnbm9zdGljcy5Nb2RlbHNBbmRVdGlscy5BdHR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BlIjogIkFuYWx5c2lzIiwNCiAgICAic2NvcmUiOiAwLjANCiAgfSwNCiAgImRhdGFzZXQiOiBbXSwNCiAgInN0YXR1cyI6IHsNCiAgICAibWVzc2FnZSI6IG51bGwsDQogICAgInN0YXR1c0lkIjogNA0KICB9LA0KICAiZGF0YVByb3ZpZGVyc01ldGFkYXRhIjogbnVsbCwNCiAgInN1Z2dlc3RlZFV0dGVyYW5jZXMiOiBudWxsDQp9' } } ] }" ) }; var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; BatchManagementClient client = BatchTestHelper.GetBatchManagementClient(handler); IPage <DetectorResponse> result = client.BatchAccount.ListDetectors("default-azurebatch-japaneast", "sampleacct"); Assert.Equal(HttpMethod.Get, handler.Method); Assert.NotNull(handler.RequestHeaders.GetValues("User-Agent")); Assert.Equal(2, result.Count()); DetectorResponse response1 = result.ElementAt(0); Assert.Equal("poolsAndNodes", response1.Name); DetectorResponse response2 = result.ElementAt(1); Assert.Equal("otherDetector", response2.Name); }
public void GalleryImage_CRUD_Tests() { using (MockContext context = MockContext.Start(this.GetType())) { EnsureClientsInitialized(context); string rgName = ComputeManagementTestUtilities.GenerateName(ResourceGroupPrefix); m_ResourcesClient.ResourceGroups.CreateOrUpdate(rgName, new ResourceGroup { Location = galleryHomeLocation }); Trace.TraceInformation("Created the resource group: " + rgName); string galleryName = ComputeManagementTestUtilities.GenerateName(GalleryNamePrefix); Gallery gallery = GetTestInputGallery(); m_CrpClient.Galleries.CreateOrUpdate(rgName, galleryName, gallery); Trace.TraceInformation(string.Format("Created the gallery: {0} in resource group: {1}", galleryName, rgName)); string galleryImageName = ComputeManagementTestUtilities.GenerateName(GalleryImageNamePrefix); GalleryImage inputGalleryImage = GetTestInputGalleryImage(); m_CrpClient.GalleryImages.CreateOrUpdate(rgName, galleryName, galleryImageName, inputGalleryImage); Trace.TraceInformation(string.Format("Created the gallery image: {0} in gallery: {1}", galleryImageName, galleryName)); GalleryImage galleryImageFromGet = m_CrpClient.GalleryImages.Get(rgName, galleryName, galleryImageName); Assert.NotNull(galleryImageFromGet); ValidateGalleryImage(inputGalleryImage, galleryImageFromGet); inputGalleryImage.Description = "Updated description."; m_CrpClient.GalleryImages.CreateOrUpdate(rgName, galleryName, galleryImageName, inputGalleryImage); Trace.TraceInformation(string.Format("Updated the gallery image: {0} in gallery: {1}", galleryImageName, galleryName)); galleryImageFromGet = m_CrpClient.GalleryImages.Get(rgName, galleryName, galleryImageName); Assert.NotNull(galleryImageFromGet); ValidateGalleryImage(inputGalleryImage, galleryImageFromGet); IPage <GalleryImage> listGalleryImagesResult = m_CrpClient.GalleryImages.ListByGallery(rgName, galleryName); Assert.Single(listGalleryImagesResult); Assert.Equal(1, listGalleryImagesResult.Count()); //Assert.Null(listGalleryImagesResult.NextPageLink); m_CrpClient.GalleryImages.Delete(rgName, galleryName, galleryImageName); listGalleryImagesResult = m_CrpClient.GalleryImages.ListByGallery(rgName, galleryName); Assert.Empty(listGalleryImagesResult); Trace.TraceInformation(string.Format("Deleted the gallery image: {0} in gallery: {1}", galleryImageName, galleryName)); m_CrpClient.Galleries.Delete(rgName, galleryName); } }
public void TestCopyLongTermRetentionBackup() { // MANUAL TEST INSTRUCTIONS // PlayBack Mode: // Make sure information below matches what is gets recorded in Session Records // Record Mode: // Create a server and database and fill in the appropriate information below // Set the weekly retention on the database so that the first backup gets picked up // Wait about 18 hours until it gets properly copied and you see the backup when run get backups // OR // Use existing instance/database that already has LTR backups // string locationName = "southeastasia"; string subscriptionId = "01c4ec88-e179-44f7-9eb0-e9719a5087ab"; string resourceGroupName = "testrg"; string sourceServerName = "ayang-stage-seas"; string sourceDatabaseName = "ltr3"; string targetServerName = "ayang-stage-seas-1"; string targetDatabaseName = "ltr1"; using (SqlManagementTestContext context = new SqlManagementTestContext(this)) { SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>(); Database database = sqlClient.Databases.Get(resourceGroupName, sourceServerName, sourceDatabaseName); // Get backups under database // IPage <LongTermRetentionBackup> backups = sqlClient.LongTermRetentionBackups.ListByResourceGroupDatabase(resourceGroupName, locationName, sourceServerName, sourceDatabaseName); Assert.True(backups.Count() >= 1); // Get a single backup using the previous call // LongTermRetentionBackup backup = sqlClient.LongTermRetentionBackups.GetByResourceGroup(resourceGroupName, locationName, sourceServerName, sourceDatabaseName, backups.First().Name); Assert.NotNull(backup); // Copy the backup to target database // string targetServerResourceId = String.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Sql/servers/{2}", subscriptionId, resourceGroupName, targetServerName); CopyLongTermRetentionBackupParameters copyParameters = new CopyLongTermRetentionBackupParameters( targetSubscriptionId: subscriptionId, targetResourceGroup: resourceGroupName, targetServerResourceId: targetServerResourceId, targetDatabaseName: targetDatabaseName); LongTermRetentionBackupOperationResult restoredDatabase = sqlClient.LongTermRetentionBackups.Copy(locationName, sourceServerName, sourceDatabaseName, backup.Name, copyParameters); } }
public void Machines_ListBySubscription() { using (MockContext context = MockContext.Start(GetType().FullName)) { var client = this.GetHybridComputeManagementClient(context); IPage <Machine> listResponse = client.Machines.ListBySubscription(); Assert.NotNull(listResponse); int count = listResponse.Count(); string nextLink = listResponse.NextPageLink; while (!string.IsNullOrEmpty(nextLink)) { IPage <Machine> listNextResponse = client.Machines.ListBySubscriptionNext(nextLink); Assert.NotNull(listNextResponse); count += listNextResponse.Count(); nextLink = listNextResponse.NextPageLink; } Assert.True(count >= 400); } }
private async Task <IEnumerable <LogicAppRun> > GetLogicAppRunsAsync() { using (LogicManagementClient managementClient = await _authentication.AuthenticateAsync()) { var odataQuery = new ODataQuery <WorkflowRunFilter> { Filter = $"StartTime ge {_startTime.UtcDateTime:O} and Status ne 'Running'" }; if (_hasCorrelationId) { odataQuery.Filter += $" and ClientTrackingId eq '{_correlationId}'"; } _logger.LogTrace( "Query logic app runs for '{LogicAppName}' in resource group '{ResourceGroup}': {Query}", _logicAppName, _resourceGroup, odataQuery.Filter); IPage <WorkflowRun> workFlowRuns = await managementClient.WorkflowRuns.ListAsync(_resourceGroup, _logicAppName, odataQuery); _logger.LogTrace("Query returned {WorkFlowRunCount} workflow runs", workFlowRuns.Count()); var logicAppRuns = new Collection <LogicAppRun>(); foreach (WorkflowRun workFlowRun in workFlowRuns) { IEnumerable <LogicAppAction> actions = await FindLogicAppRunActionsAsync(managementClient, workFlowRun.Name); if (_trackingProperties.Count > 0 && actions.Any(action => HasTrackedProperty(action.TrackedProperties)) || _trackingProperties.Count <= 0) { var logicAppRun = LogicAppConverter.ToLogicAppRun(workFlowRun, actions); logicAppRuns.Add(logicAppRun); } } _logger.LogTrace("Query resulted in {LogicAppRunCount} logic app runs", logicAppRuns.Count); return(logicAppRuns.AsEnumerable()); } }
public void PagePorts() { using (var httpTest = new HttpTest()) { Identifier portId = Guid.NewGuid(); httpTest.RespondWithJson(new PortCollection { Ports = { new Port { Id = portId } }, PortsLinks = { new Link("next", "http://api.com/next") } }); IPage <Port> ports = _cloudNetworkService.ListPorts(portId, 10); httpTest.ShouldHaveCalled(string.Format($"*/ports?marker={portId}&limit=10")); Assert.NotNull(ports); Assert.Equal(1, ports.Count()); Assert.Equal(portId, ports.First().Id); Assert.True(ports.HasNextPage); } }
public void PageSubnets() { using (var httpTest = new HttpTest()) { Identifier subnetId = Guid.NewGuid(); httpTest.RespondWithJson(new SubnetCollection { Subnets = { new Subnet { Id = subnetId } }, SubnetsLinks = { new Link("next", "http://api.com/next") } }); IPage <Subnet> subnets = _cloudNetworkService.ListSubnets(subnetId, 10); httpTest.ShouldHaveCalled(string.Format($"*/subnets?marker={subnetId}&limit=10")); Assert.NotNull(subnets); Assert.Equal(1, subnets.Count()); Assert.Equal(subnetId, subnets.First().Id); Assert.True(subnets.HasNextPage); } }
public void PageNetworks() { using (var httpTest = new HttpTest()) { Identifier networkId = Guid.NewGuid(); httpTest.RespondWithJson(new NetworkCollection { Networks = { new Network { Id = networkId } }, NetworksLinks = { new Link("next", "http://api.com/next") } }); IPage <Network> networks = _cloudNetworkService.ListNetworks(networkId, 10); httpTest.ShouldHaveCalled(string.Format($"*/networks?marker={networkId}&limit=10")); Assert.NotNull(networks); Assert.Equal(1, networks.Count()); Assert.Equal(networkId, networks.First().Id); Assert.True(networks.HasNextPage); } }
private void ValidatePolicyEventsQueryResults(IPage <PolicyEvent> queryResults) { Assert.NotNull(queryResults); var count = queryResults.Count(); Assert.True(count >= 0); if (count == 1000) { Assert.NotNull(queryResults.NextPageLink); } else { Assert.Null(queryResults.NextPageLink); } foreach (var policyEvent in queryResults) { Assert.NotNull(policyEvent); Assert.Null(policyEvent.Odataid); Assert.False(string.IsNullOrEmpty(policyEvent.Odatacontext)); Assert.True(policyEvent.Timestamp.HasValue); Assert.False(string.IsNullOrEmpty(policyEvent.ResourceId)); Assert.False(string.IsNullOrEmpty(policyEvent.PolicyAssignmentId)); Assert.False(string.IsNullOrEmpty(policyEvent.PolicyDefinitionId)); Assert.True(policyEvent.IsCompliant.HasValue); Assert.False(string.IsNullOrEmpty(policyEvent.SubscriptionId)); Assert.False(string.IsNullOrEmpty(policyEvent.PolicyDefinitionAction)); Assert.False(string.IsNullOrEmpty(policyEvent.TenantId)); Assert.False(string.IsNullOrEmpty(policyEvent.PrincipalOid)); Assert.NotNull(policyEvent.AdditionalProperties); } }
private void WriteFirstNObjects(IPage <CommunicationDetails> supportTicketCommunicationPage, List <CommunicationDetails> result) { var remainingFirst = this.MyInvocation.BoundParameters.ContainsKey("First") ? this.PagingParameters.First : ulong.MaxValue; if (remainingFirst <= (ulong)result.Count) { this.WriteObject(result.Take((int)remainingFirst).Select(x => x.ToPSSupportTicketCommunication()).ToList()); return; } if (remainingFirst > (ulong)result.Count) { remainingFirst -= (ulong)result.Count; while (remainingFirst > 0 && supportTicketCommunicationPage != null && !string.IsNullOrWhiteSpace(supportTicketCommunicationPage.NextPageLink)) { supportTicketCommunicationPage = this.SupportClient.Communications.ListNext(supportTicketCommunicationPage.NextPageLink); var resultsAdded = (int)Math.Min((ulong)supportTicketCommunicationPage.Count(), remainingFirst); result.AddRange(supportTicketCommunicationPage.Take(resultsAdded)); remainingFirst -= (ulong)resultsAdded; } } this.WriteObject(result.Select(x => x.ToPSSupportTicketCommunication()).ToList()); }
[Fact(Skip = "Manual test due to long setup time required (over 18 hours).")] public void TestUpdateLongTermRetentionBackup() { // MANUAL TEST INSTRUCTIONS // PlayBack Mode: // Remove skip flag // Record Mode: // Create a server and database and fill in the appropriate information below // Set the weekly retention on the database so that the first backup gets picked up // Wait about 18 hours until it gets properly copied and you see the backup when run get backups // string locationName = "Southeast Asia"; string resourceGroupName = "testrg"; string serverName = "ayang-stage-seas"; string databaseName = "ltr3"; using (SqlManagementTestContext context = new SqlManagementTestContext(this)) { SqlManagementClient sqlClient = context.GetClient <SqlManagementClient>(); Database database = sqlClient.Databases.Get(resourceGroupName, serverName, databaseName); // Get backups under database // IPage <LongTermRetentionBackup> backups = sqlClient.LongTermRetentionBackups.ListByResourceGroupDatabase(resourceGroupName, locationName, serverName, databaseName); Assert.True(backups.Count() >= 1); // Get a single backup using the previous call // LongTermRetentionBackup backup = sqlClient.LongTermRetentionBackups.GetByResourceGroup(resourceGroupName, locationName, serverName, databaseName, backups.First().Name); Assert.NotNull(backup); // Update the Backup Storage Redundancy of the backup // UpdateLongTermRetentionBackupParameters updateParameters = new UpdateLongTermRetentionBackupParameters(requestedBackupStorageRedundancy: "Geo"); LongTermRetentionBackupOperationResult restoredDatabase = sqlClient.LongTermRetentionBackups.Update(locationName, serverName, databaseName, backup.Name, updateParameters); } }
public async Task <ICursor <T> > GetCursorAsync <T>(Guid signalId, List <long> start, List <long> count, List <long> decimationFactor = null) { List <IPage <SEPayload> > listIPage = new List <IPage <SEPayload> >(); long queryStart = start.LastOrDefault(); long queryEnd; if (decimationFactor == null) { decimationFactor = new List <long>(); for (int i = 0; i < start.Count; i++) { decimationFactor.Add(1); } queryEnd = queryStart + count.LastOrDefault(); } else { queryEnd = queryStart + decimationFactor.LastOrDefault() * (count.LastOrDefault() - 1); } long num = count.LastOrDefault(); long factor = decimationFactor[decimationFactor.Count() - 1]; //from the second lowest rank find each line to read long lineCount = 1; //how many lines to read for (int i = 0; i < count.Count - 1; i++) { lineCount = lineCount * count[i]; } List <long> lineCursor = new List <long>(start.Count - 1); List <long> lineCounter = new List <long>(start.Count - 1); //the line cursor has every but last rank of the start point, point to the start line lineCursor.AddRange(start.Where((v, i) => i < start.Count - 1)); lineCounter.AddRange(count.Where((v, i) => i < count.Count - 1)); List <long> dimPage = new List <long>(); for (long line = 0; line < lineCount; line++) { #region Byte[] pagingState = null; string dimension = DimensionsToText(lineCursor); Cql cql = Cql.New("SELECT * FROM sepayload where parentid=? and dimensions=? and start<=? ", signalId, dimension, queryEnd); // Cql cql = Cql.New("SELECT * FROM sepayload where parentid=? and dimensions=? ", signalId, dimension); IPage <SEPayload> ipagePartialList = (await mapper.FetchPageAsync <SEPayload>(cql.WithOptions(opt => opt.SetPageSize(pagesize).SetPagingState(pagingState)))); listIPage.Add(ipagePartialList); while (ipagePartialList.PagingState != null) { pagingState = ipagePartialList.PagingState; ipagePartialList = (await mapper.FetchPageAsync <SEPayload>(cql.WithOptions(opt => opt.SetPageSize(pagesize).SetPagingState(pagingState)))); if (ipagePartialList.Count() > 0) { listIPage.Add(ipagePartialList); } } long dimPageCount = listIPage.Count() - dimPage.Sum(); dimPage.Add(dimPageCount); /***************************************/ #endregion for (var rankIndex = lineCursor.Count - 1; rankIndex >= 0; rankIndex--) { //try read next line lineCounter[rankIndex] -= 1; if (lineCounter[rankIndex] == 0) { lineCounter[rankIndex] = count[rankIndex]; lineCursor[rankIndex] = start[rankIndex]; } else { //move this rank forward lineCursor[rankIndex] += decimationFactor[rankIndex]; break; } } } Cursor <T> jdbccursor = new Cursor <T>(listIPage, start.LastOrDefault(), count, dimPage, decimationFactor.LastOrDefault()); return(jdbccursor); }
public void FileSharesSoftDeleteTest() { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType().FullName)) { var resourcesClient = StorageManagementTestUtilities.GetResourceManagementClient(context, handler); var storageMgmtClient = StorageManagementTestUtilities.GetStorageManagementClient(context, handler); // Create resource group var rgName = StorageManagementTestUtilities.CreateResourceGroup(resourcesClient); // Create storage account string accountName = TestUtilities.GenerateName("sto"); var parameters = new StorageAccountCreateParameters { Location = "eastus2euap", Kind = Kind.StorageV2, Sku = new Sku { Name = SkuName.StandardLRS } }; var account = storageMgmtClient.StorageAccounts.Create(rgName, accountName, parameters); // implement case try { // Enable share soft delete in service properties FileServiceProperties properties = storageMgmtClient.FileServices.GetServiceProperties(rgName, accountName); properties.ShareDeleteRetentionPolicy = new DeleteRetentionPolicy(); properties.ShareDeleteRetentionPolicy.Enabled = true; properties.ShareDeleteRetentionPolicy.Days = 5; properties = storageMgmtClient.FileServices.SetServiceProperties(rgName, accountName, new FileServiceProperties(shareDeleteRetentionPolicy: properties.ShareDeleteRetentionPolicy)); Assert.True(properties.ShareDeleteRetentionPolicy.Enabled); Assert.Equal(5, properties.ShareDeleteRetentionPolicy.Days); //Create 2 shares string shareName1 = TestUtilities.GenerateName("share1"); string shareName2 = TestUtilities.GenerateName("share2"); FileShare share1 = storageMgmtClient.FileShares.Create(rgName, accountName, shareName1, new FileShare(accessTier: ShareAccessTier.Hot, enabledProtocols: EnabledProtocols.NFS, rootSquash: RootSquashType.AllSquash)); Assert.Equal(shareName1, share1.Name); Assert.Equal(EnabledProtocols.NFS, share1.EnabledProtocols); Assert.Equal(RootSquashType.AllSquash, share1.RootSquash); //Assert.Equal(ShareAccessTier.Hot, share1.AccessTier); FileShare share2 = storageMgmtClient.FileShares.Create(rgName, accountName, shareName2, new FileShare(accessTier: ShareAccessTier.Cool, enabledProtocols: EnabledProtocols.SMB)); Assert.Equal(shareName2, share2.Name); Assert.Equal(EnabledProtocols.SMB, share2.EnabledProtocols); //Update 1 share share1 = storageMgmtClient.FileShares.Update(rgName, accountName, shareName1, new FileShare(accessTier: ShareAccessTier.TransactionOptimized, rootSquash: RootSquashType.RootSquash)); Assert.Equal(shareName1, share1.Name); Assert.Equal(RootSquashType.RootSquash, share1.RootSquash); //Assert.Equal(ShareAccessTier.TransactionOptimized, share1.AccessTier); // Delete 1 share storageMgmtClient.FileShares.Delete(rgName, accountName, shareName1); //List normally IPage <FileShareItem> shares = storageMgmtClient.FileShares.List(rgName, accountName); Assert.Single(shares); //List with includeDeleted string deletedShareVersion = null; shares = storageMgmtClient.FileShares.List(rgName, accountName, expand: "deleted"); Assert.Equal(2, shares.Count()); foreach (FileShareItem share in shares) { if (share.Name == shareName1) { Assert.True(share.Deleted); Assert.NotNull(share.Version); deletedShareVersion = share.Version; } } //Get not deleted share share2 = storageMgmtClient.FileShares.Get(rgName, accountName, shareName2, expand: "stats"); Assert.NotNull(share2.ShareQuota); Assert.NotNull(share2.ShareUsageBytes); //Get Deleted Share try { share2 = storageMgmtClient.FileShares.Get(rgName, accountName, shareName1); Assert.True(false, "Get Share on deleted Share should fail with NotFound."); } catch (CloudException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } // restore deleted share //Don't need sleep when playback, or Unit test will be very slow. Need sleep when record. if (HttpMockServer.Mode == HttpRecorderMode.Record) { System.Threading.Thread.Sleep(30000); } storageMgmtClient.FileShares.Restore(rgName, accountName, shareName1, shareName1, deletedShareVersion); //List normally shares = storageMgmtClient.FileShares.List(rgName, accountName); Assert.Equal(2, shares.Count()); //List with includeDeleted shares = storageMgmtClient.FileShares.List(rgName, accountName, expand: "deleted"); Assert.Equal(2, shares.Count()); } finally { // clean up storageMgmtClient.StorageAccounts.Delete(rgName, accountName); resourcesClient.ResourceGroups.Delete(rgName); } } }
public void FileSharesCreateDeleteListTest() { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType().FullName)) { var resourcesClient = StorageManagementTestUtilities.GetResourceManagementClient(context, handler); var storageMgmtClient = StorageManagementTestUtilities.GetStorageManagementClient(context, handler); // Create resource group var rgName = StorageManagementTestUtilities.CreateResourceGroup(resourcesClient); // Create storage account string accountName = TestUtilities.GenerateName("sto"); var parameters = new StorageAccountCreateParameters { Location = "eastus2euap", Kind = Kind.StorageV2, Sku = new Sku { Name = SkuName.StandardLRS } }; var account = storageMgmtClient.StorageAccounts.Create(rgName, accountName, parameters); // implement case try { string shareName = TestUtilities.GenerateName("share"); FileShare share = storageMgmtClient.FileShares.Create(rgName, accountName, shareName, new FileShare()); Assert.Null(share.Metadata); share = storageMgmtClient.FileShares.Get(rgName, accountName, shareName); Assert.Null(share.Metadata); string shareName2 = TestUtilities.GenerateName("share"); Dictionary <string, string> metaData = new Dictionary <string, string>(); metaData.Add("metadata1", "true"); metaData.Add("metadata2", "value2"); int shareQuota = 500; FileShare share2 = storageMgmtClient.FileShares.Create(rgName, accountName, shareName2, new FileShare(metadata: metaData, shareQuota: shareQuota, accessTier: ShareAccessTier.Hot)); Assert.Equal(2, share2.Metadata.Count); Assert.Equal(metaData, share2.Metadata); Assert.Equal(shareQuota, share2.ShareQuota); Assert.Equal(ShareAccessTier.Hot, share2.AccessTier); share2 = storageMgmtClient.FileShares.Get(rgName, accountName, shareName2); Assert.Equal(2, share2.Metadata.Count); Assert.Equal(metaData, share2.Metadata); Assert.Equal(shareQuota, share2.ShareQuota); Assert.Equal(ShareAccessTier.Hot, share2.AccessTier); //Delete share storageMgmtClient.FileShares.Delete(rgName, accountName, shareName); IPage <FileShareItem> fileShares = storageMgmtClient.FileShares.List(rgName, accountName); Assert.Equal(1, fileShares.Count()); storageMgmtClient.FileShares.Delete(rgName, accountName, shareName2); fileShares = storageMgmtClient.FileShares.List(rgName, accountName); Assert.Equal(0, fileShares.Count()); //Delete not exist share, won't fail (return 204) storageMgmtClient.FileShares.Delete(rgName, accountName, "notexistshare"); } finally { // clean up storageMgmtClient.StorageAccounts.Delete(rgName, accountName); resourcesClient.ResourceGroups.Delete(rgName); } } }