public static ApiNode CreateApi(string uniquebit)
 {
     var type = new ApiNodeBuilder(SymbolKind.NamedType, Accessibility.Public, $"Type{uniquebit}");
     var nonUnique = new ApiNodeBuilder(SymbolKind.NamedType, Accessibility.Public, "NonUniqueType");
     var namespaceNode = new ApiNodeBuilder(SymbolKind.Namespace, Accessibility.Public, $"Namespace{uniquebit}").WithMembers(type, nonUnique);
     var assemblyNode =
         new ApiNodeBuilder(SymbolKind.Assembly, Accessibility.Public, $"Assembly{uniquebit.GetHashCode()}").WithMembers(namespaceNode).Build();
     return assemblyNode;
 }
        public void NamespaceOnlyExcludedWhenContentsAreExcluded(Accessibility typeAccessibility, string namespaceExclusionRegex, int expectedMembers)
        {
            var type = new ApiNodeBuilder(SymbolKind.NamedType, typeAccessibility);
            var namespaceNode = new ApiNodeBuilder(SymbolKind.Namespace, signature: "Api.Tests").WithMembers(type);
            var assemblyNode = new ApiNodeBuilder(SymbolKind.Assembly).WithMembers(namespaceNode).Build();
            var filtered = GetFiltered(new PrinterConfig("", namespaceExclusionRegex), assemblyNode);

            Assert.That(filtered.Members.Count<IApiNode>(), Is.EqualTo(expectedMembers));
        }
Пример #3
0
        public static ApiNode CreateApi(string uniquebit)
        {
            var type          = new ApiNodeBuilder(SymbolKind.NamedType, Accessibility.Public, $"Type{uniquebit}");
            var nonUnique     = new ApiNodeBuilder(SymbolKind.NamedType, Accessibility.Public, "NonUniqueType");
            var namespaceNode = new ApiNodeBuilder(SymbolKind.Namespace, Accessibility.Public, $"Namespace{uniquebit}").WithMembers(type, nonUnique);
            var assemblyNode  =
                new ApiNodeBuilder(SymbolKind.Assembly, Accessibility.Public, $"Assembly{uniquebit.GetHashCode()}").WithMembers(namespaceNode).Build();

            return(assemblyNode);
        }
        public void IncludedIfMatchedByInclude()
        {
            var toIncludeRegex = @"Api\.Tests";
            var type = new ApiNodeBuilder(SymbolKind.NamedType, Accessibility.Public);
            var namespaceNode = new ApiNodeBuilder(SymbolKind.Namespace, signature: "Api.Tests").WithMembers(type);
            var assemblyNode = new ApiNodeBuilder(SymbolKind.Assembly).WithMembers(namespaceNode).Build();
            var filtered = GetFiltered(new PrinterConfig(toIncludeRegex, ""), assemblyNode);

            Assert.That(filtered.Members, Is.Not.Empty);
        }
        public void ExcludeTakesPrecedenceOverInclude()
        {
            var namespaceRegex = @"Api\.Tests";
            var type = new ApiNodeBuilder(SymbolKind.NamedType, Accessibility.Public);
            var namespaceNode = new ApiNodeBuilder(SymbolKind.Namespace, signature: "Api.Tests").WithMembers(type);
            var assemblyNode = new ApiNodeBuilder(SymbolKind.Assembly).WithMembers(namespaceNode).Build();
            var filtered = GetFiltered(new PrinterConfig(namespaceRegex, namespaceRegex), assemblyNode);

            Assert.That(filtered.Members, Is.Empty);
        }
        public void AllExcludedIfDoNotMatchInclude()
        {
            var toInclude = "Api.NonExistent";
            var type = new ApiNodeBuilder(SymbolKind.NamedType, Accessibility.Public);
            var namespaceNode = new ApiNodeBuilder(SymbolKind.Namespace, signature: "Api.Tests").WithMembers(type);
            var assemblyNode = new ApiNodeBuilder(SymbolKind.Assembly).WithMembers(namespaceNode).Build();

            var filtered = GetFiltered(new PrinterConfig(toInclude, ""), assemblyNode);
            Assert.That(filtered.Members, Is.Empty);
        }