Esempio n. 1
0
        private static IEnumerable <object[]> GetExampleData()
        {
            const string resourcePrefix = "Bicep.Core.Samples.DocsExamples.";
            const string bicepExtension = ".bicep";
            const string jsonExtension  = ".json";

            var bicepResources = Assembly.GetExecutingAssembly().GetManifestResourceNames().Where(name => name.StartsWith(resourcePrefix) && name.EndsWith(bicepExtension));

            bicepResources.Should().NotBeEmpty("examples should be included for tests");

            foreach (var bicepResource in bicepResources)
            {
                var jsonResource = bicepResource.Substring(0, bicepResource.Length - bicepExtension.Length) + jsonExtension;

                var example = new ExampleData(
                    jsonContents: DataSet.ReadFile(jsonResource),
                    bicepContents: DataSet.ReadFile(bicepResource),
                    bicepFileName: bicepResource.Substring(resourcePrefix.Length)
                    );

                yield return(new object[] { example });
            }
        }
Esempio n. 2
0
        private static IEnumerable <object[]> GetSnippets()
        {
            var snippetFileContents = JsonConvert.DeserializeObject <Dictionary <string, SnippetModel> >(DataSet.ReadFile("vscode-bicep.snippets.bicep.json"));
            var testData            = snippetFileContents.Select(x => new NamedSnippetModel(x.Key, x.Value));

            return(testData.Select(model => new object[] { model }));
        }