示例#1
0
        public void GetResourceBodyCompletionSnippets_WithDiscriminatedObjectTypeAndNoRequiredProperties_ShouldReturnEmptySnippet()
        {
            SnippetsProvider snippetsProvider = new SnippetsProvider();

            var objectTypeA = new ObjectType("objA", TypeSymbolValidationFlags.Default, new[]
            {
                new TypeProperty("discKey", new StringLiteralType("keyA")),
                new TypeProperty("keyAProp", LanguageConstants.String),
            }, null);

            var objectTypeB = new ObjectType("objB", TypeSymbolValidationFlags.Default, new[]
            {
                new TypeProperty("discKey", new StringLiteralType("keyB")),
                new TypeProperty("keyBProp", LanguageConstants.String),
            }, null);

            var discriminatedObjectType = new DiscriminatedObjectType("discObj", TypeSymbolValidationFlags.Default, "discKey", new[] { objectTypeA, objectTypeB });

            TypeSymbol typeSymbol = new ResourceType(
                ResourceTypeReference.Parse("microsoft.aadiam/azureADMetrics@2020-07-01-preview"),
                ResourceScope.ResourceGroup,
                discriminatedObjectType);

            IEnumerable <Snippet> snippets = snippetsProvider.GetResourceBodyCompletionSnippets(typeSymbol, false);

            snippets.Should().SatisfyRespectively(
                x =>
            {
                x.Prefix.Should().Be("{}");
                x.Detail.Should().Be("{}");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().Be("{\n\t$0\n}");
            });
        }
示例#2
0
        public void GetResourceBodyCompletionSnippets_WithDiscriminatedObjectTypeAndRequiredProperties_ShouldReturnRequiredPropertiesSnippet()
        {
            SnippetsProvider snippetsProvider = new SnippetsProvider();

            var objectTypeA = new ObjectType("objA", TypeSymbolValidationFlags.Default, new[]
            {
                new TypeProperty("discKey", new StringLiteralType("keyA")),
                new TypeProperty("name", new StringLiteralType("keyA"), TypePropertyFlags.Required),
                new TypeProperty("location", LanguageConstants.String, TypePropertyFlags.Required),
                new TypeProperty("id", LanguageConstants.String)
            }, null);

            var objectTypeB = new ObjectType("objB", TypeSymbolValidationFlags.Default, new[]
            {
                new TypeProperty("discKey", new StringLiteralType("keyB")),
                new TypeProperty("name", LanguageConstants.String, TypePropertyFlags.Required),
                new TypeProperty("kind", new StringLiteralType("discKey"), TypePropertyFlags.ReadOnly),
                new TypeProperty("hostPoolType", LanguageConstants.String)
            }, null);

            var discriminatedObjectType = new DiscriminatedObjectType("discObj", TypeSymbolValidationFlags.Default, "discKey", new[] { objectTypeA, objectTypeB });

            TypeSymbol typeSymbol = new ResourceType(
                ResourceTypeReference.Parse("microsoft.aadiam/azureADMetrics@2020-07-01-preview"),
                ResourceScope.ResourceGroup,
                discriminatedObjectType);

            IEnumerable <Snippet> snippets = snippetsProvider.GetResourceBodyCompletionSnippets(typeSymbol, false);

            snippets.Should().SatisfyRespectively(
                x =>
            {
                x.Prefix.Should().Be("{}");
                x.Detail.Should().Be("{}");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().Be("{\n\t$0\n}");
            },
                x =>
            {
                x.Prefix.Should().Be("required-properties-keyA");
                x.Detail.Should().Be("Required properties");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().BeEquivalentToIgnoringNewlines(@"{
	name: 'keyA'
	location: $1
	$0
}");
            },
                x =>
            {
                x.Prefix.Should().Be("required-properties-keyB");
                x.Detail.Should().Be("Required properties");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().BeEquivalentToIgnoringNewlines(@"{
	name: $1
	$0
}");
            });
        }
示例#3
0
        public void GetResourceBodyCompletionSnippets_WithNoStaticTemplate_ShouldReturnSnippets()
        {
            SnippetsProvider snippetsProvider = new SnippetsProvider();
            TypeSymbol       typeSymbol       = new ResourceType(
                ResourceTypeReference.Parse("microsoft.aadiam/azureADMetrics@2020-07-01-preview"),
                ResourceScope.ResourceGroup,
                CreateObjectType("microsoft.aadiam/azureADMetrics@2020-07-01-preview",
                                 ("name", LanguageConstants.String, TypePropertyFlags.Required),
                                 ("location", LanguageConstants.String, TypePropertyFlags.Required),
                                 ("kind", LanguageConstants.String, TypePropertyFlags.Required),
                                 ("id", LanguageConstants.String, TypePropertyFlags.ReadOnly),
                                 ("hostPoolType", LanguageConstants.String, TypePropertyFlags.Required),
                                 ("sku", CreateObjectType("applicationGroup",
                                                          ("friendlyName", LanguageConstants.String, TypePropertyFlags.None),
                                                          ("properties", CreateObjectType("properties",
                                                                                          ("loadBalancerType", LanguageConstants.String, TypePropertyFlags.Required),
                                                                                          ("preferredAppGroupType", LanguageConstants.String, TypePropertyFlags.WriteOnly)),
                                                           TypePropertyFlags.Required),
                                                          ("name", LanguageConstants.String, TypePropertyFlags.Required)),
                                  TypePropertyFlags.Required)));

            IEnumerable <Snippet> snippets = snippetsProvider.GetResourceBodyCompletionSnippets(typeSymbol, false);

            snippets.Should().SatisfyRespectively(
                x =>
            {
                x.Prefix.Should().Be("{}");
                x.Detail.Should().Be("{}");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().Be("{\n\t$0\n}");
            },
                x =>
            {
                x.Prefix.Should().Be("required-properties");
                x.Detail.Should().Be("Required properties");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().BeEquivalentToIgnoringNewlines(@"{
	name: $1
	location: $2
	sku: {
		name: $3
		properties: {
			loadBalancerType: $4
		}
	}
	kind: $5
	hostPoolType: $6
	$0
}");
            });
        }
示例#4
0
        public void GetResourceBodyCompletionSnippets_WithStaticTemplateAndResourceDependencies_ShouldReturnSnippets()
        {
            SnippetsProvider snippetsProvider = new SnippetsProvider();
            TypeSymbol       typeSymbol       = new ResourceType(
                ResourceTypeReference.Parse("Microsoft.Automation/automationAccounts/modules@2015-10-31"),
                ResourceScope.ResourceGroup,
                CreateObjectType("Microsoft.Automation/automationAccounts/modules@2015-10-31",
                                 ("name", LanguageConstants.String, TypePropertyFlags.Required),
                                 ("location", LanguageConstants.String, TypePropertyFlags.Required)));

            IEnumerable <Snippet> snippets = snippetsProvider.GetResourceBodyCompletionSnippets(typeSymbol, false);

            snippets.Should().SatisfyRespectively(
                x =>
            {
                x.Prefix.Should().Be("{}");
                x.Detail.Should().Be("{}");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().Be("{\n\t$0\n}");
            },
                x =>
            {
                x.Prefix.Should().Be("snippet");
                x.Detail.Should().Be("Automation Module");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().BeEquivalentToIgnoringNewlines(@"{
  parent: automationAccount
  name: ${3:'name'}
  properties: {
    contentLink: {
      uri: ${4:'https://content-url.nupkg'}
    }
  }
}
resource automationAccount 'Microsoft.Automation/automationAccounts@2015-10-31' = {
  name: ${1:'name'}
}
");
            },
                x =>
            {
                x.Prefix.Should().Be("required-properties");
                x.Detail.Should().Be("Required properties");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().BeEquivalentToIgnoringNewlines(@"{
	name: $1
	location: $2
	$0
}");
            });
        }
示例#5
0
        public void GetResourceBodyCompletionSnippets_WithStaticTemplateAndNoResourceDependencies_ShouldReturnSnippets()
        {
            SnippetsProvider snippetsProvider = new SnippetsProvider();
            TypeSymbol       typeSymbol       = new ResourceType(
                ResourceTypeReference.Parse("Microsoft.DataLakeStore/accounts@2016-11-01"),
                ResourceScope.ResourceGroup,
                CreateObjectType("Microsoft.DataLakeStore/accounts@2016-11-01",
                                 ("name", LanguageConstants.String, TypePropertyFlags.Required),
                                 ("location", LanguageConstants.String, TypePropertyFlags.Required)));

            IEnumerable <Snippet> snippets = snippetsProvider.GetResourceBodyCompletionSnippets(typeSymbol, false);

            snippets.Should().SatisfyRespectively(
                x =>
            {
                x.Prefix.Should().Be("{}");
                x.Detail.Should().Be("{}");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().Be("{\n\t$0\n}");
            },
                x =>
            {
                x.Prefix.Should().Be("snippet");
                x.Detail.Should().Be("Data Lake Store Account");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().BeEquivalentToIgnoringNewlines(@"{
  name: ${2:'name'}
  location: resourceGroup().location
  properties: {
    newTier: ${3|'Consumption','Commitment_1TB','Commitment_10TB','Commitment_100TB','Commitment_500TB','Commitment_1PB','Commitment_5PB'|}
    encryptionState: ${4|'Enabled','Disabled'|}
  }
}
");
            },
                x =>
            {
                x.Prefix.Should().Be("required-properties");
                x.Detail.Should().Be("Required properties");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().BeEquivalentToIgnoringNewlines(@"{
	name: $1
	location: $2
	$0
}");
            });
        }
示例#6
0
        public void GetResourceBodyCompletionSnippets_WithNoRequiredProperties_ShouldReturnEmptySnippet()
        {
            SnippetsProvider snippetsProvider = new SnippetsProvider();
            TypeSymbol       typeSymbol       = new ResourceType(
                ResourceTypeReference.Parse("microsoft.aadiam/azureADMetrics@2020-07-01-preview"),
                ResourceScope.ResourceGroup,
                CreateObjectType("microsoft.aadiam/azureADMetrics@2020-07-01-preview"));

            IEnumerable <Snippet> snippets = snippetsProvider.GetResourceBodyCompletionSnippets(typeSymbol, false);

            snippets.Should().SatisfyRespectively(
                x =>
            {
                x.Prefix.Should().Be("{}");
                x.Detail.Should().Be("{}");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().Be("{\n\t$0\n}");
            });
        }
        public void GetResourceBodyCompletionSnippets_WithStaticTemplateAndNoResourceDependencies_ShouldReturnSnippets()
        {
            SnippetsProvider snippetsProvider = new SnippetsProvider();
            TypeSymbol       typeSymbol       = new ResourceType(
                ResourceTypeReference.Parse("Microsoft.Network/dnsZones@2018-05-01"),
                ResourceScope.ResourceGroup,
                CreateObjectType("Microsoft.Network/dnsZones@2018-05-01",
                                 ("name", LanguageConstants.String, TypePropertyFlags.Required),
                                 ("location", LanguageConstants.String, TypePropertyFlags.Required)));

            IEnumerable <Snippet> snippets = snippetsProvider.GetResourceBodyCompletionSnippets(typeSymbol, false);

            snippets.Should().SatisfyRespectively(
                x =>
            {
                x.Prefix.Should().Be("{}");
                x.Detail.Should().Be("{}");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().Be("{\n\t$0\n}");
            },
                x =>
            {
                x.Prefix.Should().Be("snippet");
                x.Detail.Should().Be("DNS Zone");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().BeEquivalentToIgnoringNewlines(@"{
  name: ${2:'name'}
  location: 'global'
}
");
            },
                x =>
            {
                x.Prefix.Should().Be("required-properties");
                x.Detail.Should().Be("Required properties");
                x.CompletionPriority.Should().Be(CompletionPriority.Medium);
                x.Text.Should().BeEquivalentToIgnoringNewlines(@"{
	name: $1
	location: $2
	$0
}");
            });
        }