Example #1
0
        public void constructorTest(Namespace[] elements)
        {
            NamespaceSet        nsSet;
            HashSet <Namespace> hashSet = elements.ToHashSet();

            nsSet = new NamespaceSet(elements);
            Assert.Equal(nsSet.count, nsSet.getNamespaces().length);
            Assert.Equal(hashSet.Count, nsSet.getNamespaces().length);
            Assert.Subset(hashSet, nsSet.getNamespaces().ToHashSet());

            nsSet = new NamespaceSet(elements.AsSpan());
            Assert.Equal(nsSet.count, nsSet.getNamespaces().length);
            Assert.Equal(hashSet.Count, nsSet.getNamespaces().length);
            Assert.Subset(hashSet, nsSet.getNamespaces().ToHashSet());
        }
Example #2
0
        public void toStringMethodTest(Namespace[] elements)
        {
            var nsSet = new NamespaceSet(elements);
            var str   = nsSet.ToString();

            if (nsSet.count == 0)
            {
                Assert.Equal("[]", str);
                return;
            }

            Assert.Equal('[', str[0]);
            Assert.Equal(']', str[str.Length - 1]);

            var parts = str.Substring(1, str.Length - 2).Split(", ");

            Assert.Equal(nsSet.count, parts.Length);

            var namespaces = nsSet.getNamespaces();

            for (int i = 0; i < namespaces.length; i++)
            {
                Assert.Contains(namespaces[i].isPublic ? "<public>" : namespaces[i].ToString(), parts);
            }
        }
Example #3
0
        public void defaultValueShouldBeEmpty()
        {
            NamespaceSet nsSet = default;

            Assert.Equal(0, nsSet.count);
            Assert.Equal(0, nsSet.getNamespaces().length);
        }
Example #4
0
        public void constructorTest_withNullOrEmptySet()
        {
            NamespaceSet nsSet = new NamespaceSet(null);

            Assert.Equal(0, nsSet.count);
            Assert.Equal(0, nsSet.getNamespaces().length);

            nsSet = new NamespaceSet(new Namespace[0]);
            Assert.Equal(0, nsSet.count);
            Assert.Equal(0, nsSet.getNamespaces().length);

            nsSet = new NamespaceSet(ReadOnlySpan <Namespace> .Empty);
            Assert.Equal(0, nsSet.count);
            Assert.Equal(0, nsSet.getNamespaces().length);
        }