public async Task CanConfigureNamingOptions()
        {
            var options = new NugetFeedPluginCatalogOptions()
            {
                PluginNameOptions = new PluginNameOptions()
                {
                    PluginNameGenerator = (nameOptions, type) => type.FullName + "Modified"
                }
            };

            // Arrange
            var feed    = new NuGetFeed("nuget.org", "https://api.nuget.org/v3/index.json");
            var catalog = new NugetFeedPluginCatalog(feed, searchTerm: "tags:mocking", maxPackages: 1, configureFinder: configure =>
            {
                configure.HasName("Moq.Range");
            }, options: options);

            // Act
            await catalog.Initialize();

            var plugin = catalog.Single();

            // Assert
            Assert.EndsWith("Modified", plugin.Name);
        }
Beispiel #2
0
        public NugetFeedPluginCatalog(NuGetFeed packageFeed, string searchTerm = null,
                                      bool includePrereleases = false, int maxPackages = 128,
                                      string packagesFolder   = null, Action <TypeFinderCriteriaBuilder> configureFinder = null, Dictionary <string, TypeFinderCriteria> criterias = null,
                                      NugetFeedPluginCatalogOptions options = null)
        {
            _packageFeed        = packageFeed;
            _searchTerm         = searchTerm;
            _includePrereleases = includePrereleases;
            _maxPackages        = maxPackages;

            PackagesFolder = packagesFolder ?? Path.Combine(Path.GetTempPath(), "NugetFeedPluginCatalog", Path.GetRandomFileName());

            if (!Directory.Exists(PackagesFolder))
            {
                Directory.CreateDirectory(PackagesFolder);
            }

            if (criterias == null)
            {
                criterias = new Dictionary <string, TypeFinderCriteria>();
            }

            _options = options ?? new NugetFeedPluginCatalogOptions();

            if (configureFinder != null)
            {
                var builder = new TypeFinderCriteriaBuilder();
                configureFinder(builder);

                var criteria = builder.Build();

                _options.TypeFinderOptions.TypeFinderCriterias.Add(criteria);
            }

            foreach (var finderCriteria in criterias)
            {
                finderCriteria.Value.Tags = new List <string>()
                {
                    finderCriteria.Key
                };

                _options.TypeFinderOptions.TypeFinderCriterias.Add(finderCriteria.Value);
            }
        }