Exemple #1
0
        public void Create_SupportedCharacters_DoesNotThrow()
        {
            var trie = new VariableTrie <string>();

            trie.AddValue("_", "_");

            foreach (char c in Enumerable.Range('a', 26))
            {
                trie.AddValue(c.ToString(), c.ToString());
            }

            foreach (char c in Enumerable.Range('A', 26))
            {
                trie.AddValue(c.ToString(), c.ToString());
            }

            foreach (char c in Enumerable.Range('0', 10))
            {
                trie.AddValue(c.ToString(), c.ToString());
            }

            foreach (char c in Enumerable.Range('a', 26))
            {
                trie.GetMatches(c.ToString()).Should().HaveCount(1);
            }

            foreach (char c in Enumerable.Range('0', 10))
            {
                trie.GetMatches(c.ToString()).Should().HaveCount(1);
            }

            trie.GetMatches("_").Should().HaveCount(1);
        }
Exemple #2
0
        public void Create_NotSupportedCharacters_Throws()
        {
            var    trie = new VariableTrie <string>();
            Action act  = () => trie.AddValue("*", "throws");

            act.Should().ThrowExactly <InvalidOperationException>();
        }
 internal RouteSettings(
     string route,
     CompiledPattern compiledRoute,
     VariableTrie <string> variableTrie,
     ProxySettings?proxySettings)
 {
     Route         = route;
     CompiledRoute = compiledRoute;
     VariableTrie  = variableTrie;
     Proxy         = proxySettings;
 }
Exemple #4
0
        public void Create_SimpleTry_Success()
        {
            // Arrange
            var items = new[]
            {
                SystemVariableNames.ContentLength,
                SystemVariableNames.ContentType,
                SystemVariableNames.Host,
                SystemVariableNames.RequestMethod,
                SystemVariableNames.RequestScheme,
                SystemVariableNames.RequestPathBase,
                SystemVariableNames.RequestPath,
                SystemVariableNames.RequestQueryString,
                SystemVariableNames.RequestEncodedUrl,
                SystemVariableNames.RemoteAddress,
                SystemVariableNames.RemotePort,
                SystemVariableNames.ServerAddress,
                SystemVariableNames.ServerName,
                SystemVariableNames.ServerPort,
                SystemVariableNames.ServerProtocol,
            };

            // Act
            var trie = new VariableTrie <string>();

            for (int i = 0; i < items.Length; i++)
            {
                trie.AddValue(items[i], items[i]);
            }

            // Assert
            trie.GetMatches("content").Should().BeEmpty();
            trie.GetMatches(string.Empty).Should().BeEmpty();
            trie.GetMatches("*&-").Should().BeEmpty();
            trie.TryGetBestMatch("content", out _, out _).Should().BeFalse();
            trie.TryGetBestMatch(string.Empty, out _, out _).Should().BeFalse();
            trie.TryGetBestMatch("*&-", out _, out _).Should().BeFalse();

            trie.GetMatches(SystemVariableNames.RequestPathBase)
            .Should()
            .BeEquivalentTo(
                new[]