public void AzureIMSTestFieldGoodValueVerification() { // there are three fields we verify within the AzureInstanceComputeMetadata class, test the // verification routines AzureInstanceComputeMetadata md = new AzureInstanceComputeMetadata(); List <string> acceptableNames = new List <string> { "acceptable-(Name)_Here", "A", "0123456789012345678901234567890123456789012345678901234567890123", "(should-work-fine)" }; foreach (string goodName in acceptableNames) { md.Name = goodName; Assert.Equal(md.Name, md.VerifyExpectedValue("name")); } List <string> acceptableResourceGroupNames = new List <string> { "1", "acceptable_resourceGr0uP.Name-Here", "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._-", "0123startsWithANumber" }; foreach (string goodResourceGroupName in acceptableResourceGroupNames) { md.ResourceGroupName = goodResourceGroupName; Assert.Equal(md.ResourceGroupName, md.VerifyExpectedValue("resourceGroupName")); } var subId = Guid.NewGuid(); List <string> acceptableSubscriptionIds = new List <string> { subId.ToString(), subId.ToString().ToLowerInvariant(), subId.ToString().ToUpperInvariant() }; foreach (string goodSubscriptionId in acceptableSubscriptionIds) { md.SubscriptionId = goodSubscriptionId; Assert.Equal(md.SubscriptionId, md.VerifyExpectedValue("subscriptionId")); } }
public void AzureIMSTestFieldBadValuesFailVerification() { // there are three fields we verify within the AzureInstanceComputeMetadata class, test the // verification routines AzureInstanceComputeMetadata md = new AzureInstanceComputeMetadata(); List <string> unacceptableNames = new List <string> { "unacceptable name spaces", "string-too-long-0123456789012345678901234567890123456789012345678901234567890123456789", "unacceptable=name+punctuation", string.Empty }; foreach (string failName in unacceptableNames) { md.Name = failName; Assert.Empty(md.VerifyExpectedValue("name")); } List <string> unacceptableResourceGroupNames = new List <string> { "unacceptable name spaces", "string-too-long-012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", "unacceptable#punctuation!", "ends.with.a.period.", string.Empty }; foreach (string failResGrpName in unacceptableResourceGroupNames) { md.ResourceGroupName = failResGrpName; Assert.Empty(md.VerifyExpectedValue("resourceGroupName")); } List <string> unacceptableSubscriptionIds = new List <string> { "unacceptable name not a guid", string.Empty }; foreach (string failSubscriptionId in unacceptableSubscriptionIds) { md.SubscriptionId = failSubscriptionId; Assert.Empty(md.VerifyExpectedValue("subscriptionId")); } }