コード例 #1
0
        public void ContainsPrefix_HasEntries_PrefixMatch_WithDot(string prefix)
        {
            // Arrange
            var keys      = new string[] { "a.x", "b.xy", "c.x.y", "d.x.z[0]" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(prefix);

            // Assert
            Assert.True(result);
        }
コード例 #2
0
        public void ContainsPrefix_ReturnsTrue_IfTheContainerHasAnExactMatch(string prefix)
        {
            // Arrange
            var keys      = new string[] { "bc", "a", "abc", "d" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(prefix);

            // Assert
            Assert.True(result);
        }
コード例 #3
0
        public void ContainsPrefix_HasEntries_NoMatch(string prefix)
        {
            // Arrange
            var keys      = new string[] { "ax", "bx", "cx", "dx" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(prefix);

            // Assert
            Assert.False(result);
        }
コード例 #4
0
        public void ContainsPrefix_EmptyCollection_EmptyString_False()
        {
            // Arrange
            var keys      = new string[] { };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(string.Empty);

            // Assert
            Assert.False(result);
        }
コード例 #5
0
        public void ContainsPrefix_HasEntries_EmptyString_True()
        {
            // Arrange
            var keys      = new string[] { "some.prefix" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(string.Empty);

            // Assert
            Assert.True(result);
        }
コード例 #6
0
        public void ContainsPrefix_HasEntries_PrefixMatch_WithSquareBrace(string prefix)
        {
            // Arrange
            var keys      = new string[] { "a[x]", "d[x].y", "e.a.b[foo].bar" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(prefix);

            // Assert
            Assert.True(result);
        }
コード例 #7
0
        public void ContainsPrefix_ReturnsTrue_IfTheContainerHasAnExactMatch(string prefix)
        {
            // Arrange
            var keys = new string[] { "bc", "a", "abc", "d" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(prefix);

            // Assert
            Assert.True(result);
        }
コード例 #8
0
        public void ContainsPrefix_ReturnsFalse_IfPrefixDoesNotMatch(string prefix)
        {
            // Arrange
            var keys      = new string[] { "a.b", "a.bc", "a.b[c]", "a.b[0]" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(prefix);

            // Assert
            Assert.False(result);
        }
コード例 #9
0
        public void ContainsPrefix_HasEntries_NoMatch(string prefix)
        {
            // Arrange
            var keys = new string[] { "ax", "bx", "cx", "dx" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(prefix);

            // Assert
            Assert.False(result);
        }
コード例 #10
0
        public void ContainsPrefix_HasEntries_EmptyString_True()
        {
            // Arrange
            var keys = new string[] { "some.prefix" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(string.Empty);

            // Assert
            Assert.True(result);
        }
コード例 #11
0
        public void ContainsPrefix_EmptyCollection_EmptyString_False()
        {
            // Arrange
            var keys = new string[] { };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(string.Empty);

            // Assert
            Assert.False(result);
        }
コード例 #12
0
        public void ContainsPrefix_HasEntries_ExactMatch(string prefix)
        {
            // Arrange
            var keys      = new string[] { "a", "b", "c", "d" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(prefix);

            // Assert
            Assert.True(result);
        }
コード例 #13
0
        public void ContainsPrefix_HasEntries_PartialAndPrefixMatch_WithSquareBrace(int partialMatches)
        {
            // Arrange
            var keys = new string[partialMatches + 1];

            for (var i = 0; i < partialMatches; i++)
            {
                keys[i] = $"aa[{i}]";
            }
            keys[partialMatches] = "a[0]"; // Sorted after all "aa" keys.
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix("a");

            // Assert
            Assert.True(result);
        }
コード例 #14
0
        public void ContainsPrefix_HasEntries_PrefixMatch_WithDot(string prefix)
        {
            // Arrange
            var keys = new string[] { "a.x", "b.xy", "c.x.y", "d.x.z[0]" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(prefix);

            // Assert
            Assert.True(result);
        }
コード例 #15
0
        public void ContainsPrefix_HasEntries_PrefixMatch_WithSquareBrace(string prefix)
        {
            // Arrange
            var keys = new string[] { "a[x]", "d[x].y", "e.a.b[foo].bar" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(prefix);

            // Assert
            Assert.True(result);
        }
コード例 #16
0
        public void ContainsPrefix_ReturnsFalse_IfPrefixDoesNotMatch(string prefix)
        {
            // Arrange
            var keys = new string[] { "a.b", "a.bc", "a.b[c]", "a.b[0]" };
            var container = new PrefixContainer(keys);

            // Act
            var result = container.ContainsPrefix(prefix);

            // Assert
            Assert.False(result);
        }