<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tavis.UriTemplates;
using Xunit;
using Xunit.Extensions;

namespace UriTemplateTests
{
    public class UriTemplateTableTests
    {

        



        [Theory,
        InlineData("/","root"),
        InlineData("/baz/fod/burg",""),
        InlineData("/baz/kit", "kit"),
        InlineData("/baz/fod", "baz"),
        InlineData("/baz/fod/blob", "blob"),
        InlineData("/glah/flid/blob", "goo")]
        public void FindPathTemplates(string url, string key)
        {
            var table = new UriTemplateTable();
            table.Add("root", new UriTemplate("/"));
            table.Add("foo", new UriTemplate("/foo/{bar}"));
            table.Add("kit", new UriTemplate("/baz/kit"));
            table.Add("baz", new UriTemplate("/baz/{bar}"));
            table.Add("blob", new UriTemplate("/baz/{bar}/blob"));
            table.Add("goo", new UriTemplate("/{goo}/{bar}/blob"));


            var result = table.Match(new Uri(url, UriKind.RelativeOrAbsolute));

            if (string.IsNullOrEmpty(key))
            {
                Assert.Null(result);
            }
            else
            {
                Assert.Equal(key, result.Key);
            }
        }

        [Theory,
     InlineData("/games", "games"),
     InlineData("/games/monopoly/Setup/23", "gamessetup"),
     InlineData("/games/monopoly/Resources/foo/23", "resource"),
     InlineData("/games/monopoly/22/Chat/33", "chat"),     
     InlineData("/games/monopoly/22/State/33", "state"),     
    ]
        public void FindTemplatesInGamesApi(string url, string key)
        {
            var table = new UriTemplateTable();
            table.Add("games", new UriTemplate("/games"));
            table.Add("gamessetup", new UriTemplate("/games/{gametitle}/Setup/{gamesid}"));
            table.Add("resource", new UriTemplate("/games/{gametitle}/Resources/{resourcetype}/{resourceid}"));
            table.Add("chat", new UriTemplate("/games/{gametitle}/{gameid}/Chat/{chatid}"));
            table.Add("state", new UriTemplate("/games/{gametitle}/{gameid}/State/{stateid}"));


            var result = table.Match(new Uri(url, UriKind.RelativeOrAbsolute));

            if (string.IsNullOrEmpty(key))
            {
                Assert.Null(result);
            }
            else
            {
                Assert.Equal(key, result.Key);
            }
        }


                [Theory,
     InlineData("/foo?x=1&y=2", "fooxy3"),
     InlineData("/foo?x=1", "fooxy2"),
     InlineData("/foo?y=2", "fooxy"),
     InlineData("/foo", "fooxy"),
    ]
        public void FindTemplatesWithQueryStrings(string url, string key)
        {
            var table = new UriTemplateTable();
            table.Add("fooxy3", new UriTemplate("/foo?x={x}&y={y}"));
            table.Add("fooxy2", new UriTemplate("/foo?x={x}{&y}"));
            table.Add("fooxy", new UriTemplate("/foo{?x,y}"));
            table.Add("foo", new UriTemplate("/foo"));
 

            var result = table.Match(new Uri(url, UriKind.RelativeOrAbsolute));

            if (string.IsNullOrEmpty(key))
            {
                Assert.Null(result);
            }
            else
            {
                Assert.Equal(key, result.Key);
            }
        }

    }

    }


<commit_msg>Added some guidance for building tables<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tavis.UriTemplates;
using Xunit;
using Xunit.Extensions;

namespace UriTemplateTests
{
    public class UriTemplateTableTests
    {

        



        [Theory,
        InlineData("/","root"),
        InlineData("/baz/fod/burg",""),
        InlineData("/baz/kit", "kit"),
        InlineData("/baz/fod", "baz"),
        InlineData("/baz/fod/blob", "blob"),
        InlineData("/glah/flid/blob", "goo")]
        public void FindPathTemplates(string url, string key)
        {
            var table = new UriTemplateTable();  // Shorter paths and literal path segments should be added to the table first.
            table.Add("root", new UriTemplate("/"));
            table.Add("foo", new UriTemplate("/foo/{bar}"));
            table.Add("kit", new UriTemplate("/baz/kit"));
            table.Add("baz", new UriTemplate("/baz/{bar}"));
            table.Add("blob", new UriTemplate("/baz/{bar}/blob"));
            table.Add("goo", new UriTemplate("/{goo}/{bar}/blob"));


            var result = table.Match(new Uri(url, UriKind.RelativeOrAbsolute));

            if (string.IsNullOrEmpty(key))
            {
                Assert.Null(result);
            }
            else
            {
                Assert.Equal(key, result.Key);
            }
        }

        [Theory,
     InlineData("/games", "games"),
     InlineData("/games/monopoly/Setup/23", "gamessetup"),
     InlineData("/games/monopoly/Resources/foo/23", "resource"),
     InlineData("/games/monopoly/22/Chat/33", "chat"),     
     InlineData("/games/monopoly/22/State/33", "state"),     
    ]
        public void FindTemplatesInGamesApi(string url, string key)
        {
            var table = new UriTemplateTable();
            table.Add("games", new UriTemplate("/games"));
            table.Add("gamessetup", new UriTemplate("/games/{gametitle}/Setup/{gamesid}"));
            table.Add("resource", new UriTemplate("/games/{gametitle}/Resources/{resourcetype}/{resourceid}"));
            table.Add("chat", new UriTemplate("/games/{gametitle}/{gameid}/Chat/{chatid}"));
            table.Add("state", new UriTemplate("/games/{gametitle}/{gameid}/State/{stateid}"));


            var result = table.Match(new Uri(url, UriKind.RelativeOrAbsolute));

            if (string.IsNullOrEmpty(key))
            {
                Assert.Null(result);
            }
            else
            {
                Assert.Equal(key, result.Key);
            }
        }


                [Theory,
     InlineData("/foo?x=1&y=2", "fooxy3"),
     InlineData("/foo?x=1", "fooxy2"),
     InlineData("/foo?y=2", "fooxy"),
     InlineData("/foo", "fooxy"),
    ]
        public void FindTemplatesWithQueryStrings(string url, string key)
        {
            var table = new UriTemplateTable();   // More restrictive templates should have priority over less restrictuve ones
            table.Add("fooxy3", new UriTemplate("/foo?x={x}&y={y}"));
            table.Add("fooxy2", new UriTemplate("/foo?x={x}{&y}"));
            table.Add("fooxy", new UriTemplate("/foo{?x,y}"));
            table.Add("foo", new UriTemplate("/foo"));
 

            var result = table.Match(new Uri(url, UriKind.RelativeOrAbsolute));

            if (string.IsNullOrEmpty(key))
            {
                Assert.Null(result);
            }
            else
            {
                Assert.Equal(key, result.Key);
            }
        }

    }

    }



{'fraction_non_alphanumeric': 0.16228323699421965, 'fraction_numerical': 0.005780346820809248, 'mean_word_length': 2.015686274509804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5822171', 'n_tokens_mistral': 2155, 'n_tokens_neox': 1988, 'n_words': 344}