Example #1
0
        //public static CognitiveServicesAccount CreateAndValidateAccountWithOnlyRequiredParameters(CognitiveServicesManagementClient cognitiveServicesMgmtClient, string rgName, string skuName, string accountType = Kind.Recommendations, string location = null)
        //{
        //    // Create account with only required params
        //    var accountName = TestUtilities.GenerateName("csa");
        //    var parameters = new CognitiveServicesAccountCreateParameters
        //    {
        //        Sku = new Microsoft.Azure.Management.CognitiveServices.Models.Sku { Name = skuName },
        //        Kind = accountType,
        //        Location = location ?? DefaultLocation,
        //        Properties = new object(),
        //    };
        //    var account = cognitiveServicesMgmtClient.CognitiveServicesAccounts.Create(rgName, accountName, parameters);
        //    VerifyAccountProperties(account, false, accountType, skuName, location ?? DefaultLocation);

        //    return account;
        //}

        public static void VerifyAccountProperties(LocationBasedServicesAccount account, bool useDefaults, string skuName = DefaultSkuName, string location = "global")
        {
            Assert.NotNull(account); // verifies that the account is actually created
            Assert.NotNull(account.Id);
            Assert.NotNull(account.Location);
            Assert.NotNull(account.Name);

            Assert.NotNull(account.Sku);
            Assert.NotNull(account.Sku.Tier);

            if (useDefaults)
            {
                Assert.Equal(LocationBasedServicesManagementTestUtilities.DefaultLocation, account.Location);
                Assert.Equal(LocationBasedServicesManagementTestUtilities.DefaultSkuName, account.Sku.Name);

                Assert.NotNull(account.Tags);
                Assert.Equal(2, account.Tags.Count);
                Assert.Equal("value1", account.Tags["key1"]);
                Assert.Equal("value2", account.Tags["key2"]);
            }
            else
            {
                Assert.Equal(skuName, account.Sku.Name);
                Assert.Equal(location, account.Location);
            }
        }
 protected void WriteLocationBasedServicesAccount(LocationBasedServicesAccount locationBasedServicesAccount)
 {
     if (locationBasedServicesAccount != null)
     {
         WriteObject(Models.PSLocationBasedServicesAccount.Create(locationBasedServicesAccount));
     }
 }
 public PSLocationBasedServicesAccount(LocationBasedServicesAccount locationBasedServicesAccount)
 {
     this.ResourceGroupName = ParseResourceGroupFromId(locationBasedServicesAccount.Id);
     this.AccountName       = locationBasedServicesAccount.Name;
     this.Id           = locationBasedServicesAccount.Id;
     this.Location     = locationBasedServicesAccount.Location;
     this.Sku          = new PSLocationBasedServicesAccountSku(locationBasedServicesAccount.Sku);
     this.ResourceType = locationBasedServicesAccount.Type;
     this.Tags         = locationBasedServicesAccount.Tags;
 }
        public static PSLocationBasedServicesAccount Create(LocationBasedServicesAccount locationBasedServicesAccount)
        {
            var result = new PSLocationBasedServicesAccount(locationBasedServicesAccount);

            return(result);
        }