コード例 #1
0
        public void SearchTree_WithMultipleSources_Match(string packageNamespaces, string term)
        {
            // Arrange
            PackageNamespacesConfiguration configuration = PackageNamespacesConfigurationUtility.GetPackageNamespacesConfiguration(packageNamespaces);
            SearchTree searchTree = new SearchTree(configuration);

            // Act & Assert
            IReadOnlyList <string> configuredSources = searchTree.GetConfiguredPackageSources(term);

            Assert.Equal(1, configuredSources.Count);
            Assert.True(configuredSources[0].StartsWith(term.Trim().Substring(0, 5)));
        }
コード例 #2
0
        public void SearchTree_WithOneSource_Match(string packageNamespaces, string term)
        {
            // Arrange
            PackageNamespacesConfiguration configuration = PackageNamespacesConfigurationUtility.GetPackageNamespacesConfiguration(packageNamespaces);
            SearchTree searchTree = new SearchTree(configuration);

            // Act & Assert
            configuration.AreNamespacesEnabled.Should().BeTrue();
            IReadOnlyList <string> configuredSources = searchTree.GetConfiguredPackageSources(term);

            Assert.Equal(1, configuredSources.Count);
            Assert.Equal(configuration.Namespaces.Keys.First().Trim(), configuredSources[0]);
        }
コード例 #3
0
        public void SearchTree_InvalidSearchInput_Throws(string packageNamespaces, string term)
        {
            // Arrange
            PackageNamespacesConfiguration configuration = PackageNamespacesConfigurationUtility.GetPackageNamespacesConfiguration(packageNamespaces);

            // Act & Assert
            configuration.AreNamespacesEnabled.Should().BeTrue();

            var exception = Assert.Throws <ArgumentException>(
                () => configuration.GetConfiguredPackageSources(term));

            Assert.Equal("Argument cannot be null, empty, or whitespace only." + Environment.NewLine + "Parameter name: term", exception.Message);
        }
コード例 #4
0
 private SearchTree GetSearchTree(string packageNamespaces)
 {
     return(new SearchTree(PackageNamespacesConfigurationUtility.GetPackageNamespacesConfiguration(packageNamespaces)));
 }