Exemplo n.º 1
0
        public void TestCreateListDeleteAvailabilityGroupListeners()
        {
            using (SqlVirtualMachineTestContext context = new SqlVirtualMachineTestContext(this))
            {
                string groupName      = "test-group";
                string agListenerName = "AGListener";
                IAvailabilityGroupListenersOperations sqlOperations = context.getSqlClient().AvailabilityGroupListeners;

                // Create AG listener
                AvailabilityGroupListener agListener = SqlVirtualMachineTestBase.CreateAGListener(context, agListenerName, groupName);

                // Recover
                AvailabilityGroupListener agListener2 = sqlOperations.Get(context.resourceGroup.Name, groupName, agListener.Name);
                SqlVirtualMachineTestBase.ValidateAGListener(agListener, agListener2);

                // List
                IPage <AvailabilityGroupListener> list = sqlOperations.ListByGroup(context.resourceGroup.Name, groupName);
                foreach (AvailabilityGroupListener ag in list)
                {
                    if (ag.Id.Equals(agListener.Id))
                    {
                        SqlVirtualMachineTestBase.ValidateAGListener(agListener, ag);
                    }
                }

                // Delete AG listener
                sqlOperations.Delete(context.resourceGroup.Name, groupName, agListenerName);
                list = sqlOperations.ListByGroup(context.resourceGroup.Name, groupName);
                Assert.False(list.GetEnumerator().MoveNext());
            }
        }
 public void TestListOperations()
 {
     using (SqlVirtualMachineTestContext context = new SqlVirtualMachineTestContext(this))
     {
         context.getSqlClient().Operations.ListWithHttpMessagesAsync();
     }
 }
        public void TestCreateUpdateGetSqlVirtualMachineGroup()
        {
            using (SqlVirtualMachineTestContext context = new SqlVirtualMachineTestContext(this))
            {
                // Create SQL VM group
                ISqlVirtualMachineGroupsOperations sqlOperations = context.getSqlClient().SqlVirtualMachineGroups;
                StorageAccount         storageAccount            = VirtualMachineTestBase.CreateStorageAccount(context);
                SqlVirtualMachineGroup group = SqlVirtualMachineTestBase.CreateSqlVirtualMachineGroup(context, storageAccount, "test-group");

                // Update
                string key = "test", value = "updateTag";
                sqlOperations.Update(context.resourceGroup.Name, group.Name, new SqlVirtualMachineGroupUpdate()
                {
                    Tags = new Dictionary <string, string>
                    {
                        { key, value }
                    }
                });

                // Get
                SqlVirtualMachineGroup group2 = sqlOperations.Get(context.resourceGroup.Name, group.Name);
                SqlVirtualMachineTestBase.ValidateSqlVirtualMachineGroups(group, group2, false);
                Assert.Equal(1, group2.Tags.Keys.Count);
                Assert.Equal(value, group2.Tags[key]);
            }
        }
        public void TestListSqlVirtualMachineGroup()
        {
            using (SqlVirtualMachineTestContext context = new SqlVirtualMachineTestContext(this))
            {
                // Create SQL VM group
                ISqlVirtualMachineGroupsOperations sqlOperations = context.getSqlClient().SqlVirtualMachineGroups;
                StorageAccount         storageAccount            = VirtualMachineTestBase.CreateStorageAccount(context);
                SqlVirtualMachineGroup group = SqlVirtualMachineTestBase.CreateSqlVirtualMachineGroup(context, storageAccount, "test-group");

                // List
                IPage <SqlVirtualMachineGroup>       list = sqlOperations.List();
                IEnumerator <SqlVirtualMachineGroup> iter = list.GetEnumerator();
                int count = 0;
                while (iter.MoveNext())
                {
                    SqlVirtualMachineGroup group2 = iter.Current;
                    if (group.Id.Equals(group2.Id))
                    {
                        SqlVirtualMachineTestBase.ValidateSqlVirtualMachineGroups(group, group2);
                        count++;
                    }
                }
                iter.Dispose();
                Assert.Equal(1, count);
            }
        }
        public void TestCreateGetUpdateDeleteSqlVirtualMachine()
        {
            using (SqlVirtualMachineTestContext context = new SqlVirtualMachineTestContext(this))
            {
                // Create SQL VM
                ISqlVirtualMachinesOperations sqlOperations = context.getSqlClient().SqlVirtualMachines;
                Dictionary <string, SqlVirtualMachineModel> sqlVirtualMachines = new Dictionary <string, SqlVirtualMachineModel>();
                SqlVirtualMachineModel sqlVM = null;
                for (int i = 0; i < 3; i++)
                {
                    sqlVM = SqlVirtualMachineTestBase.CreateSqlVirtualMachine(context);
                    Assert.NotNull(sqlVM);
                    sqlVirtualMachines[sqlVM.Id] = sqlVM;
                }

                // Recover
                foreach (string id in sqlVirtualMachines.Keys)
                {
                    sqlVM = sqlOperations.Get(context.resourceGroup.Name, sqlVirtualMachines[id].Name);
                    Assert.NotNull(sqlVM);
                    SqlVirtualMachineTestBase.ValidateSqlVirtualMachine(sqlVM, sqlVirtualMachines[id]);
                }

                // Update
                string key = "test", value = "updateTag";
                sqlOperations.Update(context.resourceGroup.Name, sqlVM.Name, new SqlVirtualMachineUpdate
                {
                    Tags = new Dictionary <string, string>
                    {
                        { key, value }
                    }
                });
                SqlVirtualMachineModel sqlVM2            = sqlOperations.Get(context.resourceGroup.Name, sqlVM.Name);
                SqlVirtualMachineTestBase.ValidateSqlVirtualMachine(sqlVM, sqlVM2, sameTags: false);
                Assert.Equal(1, sqlVM2.Tags.Keys.Count);
                Assert.Equal(value, sqlVM2.Tags[key]);

                // Delete
                sqlOperations.Delete(context.resourceGroup.Name, sqlVM2.Name);
                sqlVirtualMachines.Remove(sqlVM2.Id);

                // List
                IPage <SqlVirtualMachineModel> recovered = sqlOperations.List();
                var iter = recovered.GetEnumerator();
                while (iter.MoveNext())
                {
                    sqlVM = iter.Current;
                    Assert.NotEqual(sqlVM.Id, sqlVM2.Id);
                    if (sqlVirtualMachines.ContainsKey(sqlVM.Id))
                    {
                        SqlVirtualMachineTestBase.ValidateSqlVirtualMachine(sqlVM, sqlVirtualMachines[sqlVM.Id]);
                        sqlVirtualMachines.Remove(sqlVM.Id);
                    }
                }
                Assert.Empty(sqlVirtualMachines.Keys);
                iter.Dispose();
            }
        }
        public void TestListByGroupSqlVirtualMachine()
        {
            using (SqlVirtualMachineTestContext context = new SqlVirtualMachineTestContext(this))
            {
                // Create Sql VM
                ISqlVirtualMachinesOperations sqlOperations = context.getSqlClient().SqlVirtualMachines;
                SqlVirtualMachineModel        sqlVM         = SqlVirtualMachineTestBase.CreateSqlVirtualMachine(context);
                Assert.NotNull(sqlVM);

                // List by group
                IPage <SqlVirtualMachineModel> recovered = sqlOperations.ListByResourceGroup(context.resourceGroup.Name);
                var iter = recovered.GetEnumerator();
                Assert.NotNull(iter);
                iter.MoveNext();
                SqlVirtualMachineModel sqlVM2 = iter.Current;
                Assert.NotNull(sqlVM2);
                SqlVirtualMachineTestBase.ValidateSqlVirtualMachine(sqlVM, sqlVM2);
                Assert.False(iter.MoveNext());
                iter.Dispose();
            }
        }
        public void TestCreateGetDeleteSqlVirtualMachineGroup()
        {
            using (SqlVirtualMachineTestContext context = new SqlVirtualMachineTestContext(this))
            {
                // Create SQL VM group
                ISqlVirtualMachineGroupsOperations sqlOperations = context.getSqlClient().SqlVirtualMachineGroups;
                StorageAccount         storageAccount            = VirtualMachineTestBase.CreateStorageAccount(context);
                SqlVirtualMachineGroup group = SqlVirtualMachineTestBase.CreateSqlVirtualMachineGroup(context, storageAccount, "test-group");

                // Recover
                SqlVirtualMachineGroup group2 = sqlOperations.Get(context.resourceGroup.Name, group.Name);
                SqlVirtualMachineTestBase.ValidateSqlVirtualMachineGroups(group, group2);

                // Delete
                sqlOperations.Delete(context.resourceGroup.Name, group.Name);

                // Recover
                IPage <SqlVirtualMachineGroup>       list = sqlOperations.ListByResourceGroup(context.resourceGroup.Name);
                IEnumerator <SqlVirtualMachineGroup> iter = list.GetEnumerator();
                Assert.False(iter.MoveNext());
            }
        }