Exemplo n.º 1
0
        public void CanSkipInvalidEntriesSearchMetadata()
        {
            using EnvironmentSettingsHelper environmentSettingsHelper = new EnvironmentSettingsHelper();
            string content = File.ReadAllText("NuGetTemplateSearchInfoWithInvalidData.json");
            var    config  = new NuGetSearchCacheConfig("NuGetTemplateSearchInfoWithInvalidData.json");

            Assert.True(FileMetadataTemplateSearchCacheReader.TryReadDiscoveryMetadata(
                            environmentSettingsHelper.CreateEnvironment(virtualize: true),
                            content,
                            config,
                            out TemplateDiscoveryMetadata discoveryMetadata));
            Assert.Equal(1, discoveryMetadata.TemplateCache.Count);
            Assert.Equal(1, discoveryMetadata.PackToTemplateMap.Count);

            Assert.IsType <BlobStorageTemplateInfo>(discoveryMetadata.TemplateCache[0]);
            Assert.Equal("Microsoft.AzureFunctions.ProjectTemplate.CSharp.3.x", discoveryMetadata.TemplateCache[0].Identity);
        }
Exemplo n.º 2
0
        public void CanReadSearchMetadata()
        {
            using EnvironmentSettingsHelper environmentSettingsHelper = new EnvironmentSettingsHelper();
            string content = File.ReadAllText("NuGetTemplateSearchInfo.json");
            var    config  = new NuGetSearchCacheConfig("NuGetTemplateSearchInfo.json");

            Assert.True(FileMetadataTemplateSearchCacheReader.TryReadDiscoveryMetadata(
                            environmentSettingsHelper.CreateEnvironment(virtualize: true),
                            content,
                            config,
                            out TemplateDiscoveryMetadata discoveryMetadata));
            Assert.Equal(2, discoveryMetadata.TemplateCache.Count);
            Assert.Equal(1, discoveryMetadata.PackToTemplateMap.Count);

            Assert.IsType <BlobStorageTemplateInfo>(discoveryMetadata.TemplateCache[0]);

            //can read tags
            Assert.Equal(2, discoveryMetadata.TemplateCache[0].Tags.Count);

            //can read parameters: 2 tags + 3 cache parameters
            Assert.Equal(5, discoveryMetadata.TemplateCache[0].Parameters.Count);
        }
        private bool TryReadScraperOutput(string scrapeFilePath, out TemplateDiscoveryMetadata discoveryMetadata)
        {
            ISearchCacheConfig cacheConfig = new NuGetSearchCacheConfig(scrapeFilePath);

            return(FileMetadataTemplateSearchCacheReader.TryReadDiscoveryMetadata(_environmentSettings, cacheConfig, out discoveryMetadata));
        }