<commit_before>namespace Snittlistan.Test
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Web;
    using System.Web.Routing;
    using Moq;
    using MvcContrib.TestHelper;

    public static class RouteTestHelper
    {
        public static void Maps(this RouteCollection routes, string httpVerb, string url, object expectations)
        {
            var routeData = RetrieveRouteData(routes, httpVerb, url);
            routeData.ShouldNotBeNull("Should have found the route");

            foreach (var property in GetProperties(expectations))
            {
                string.Equals(
                    property.Value.ToString(),
                    routeData.Values[property.Name].ToString(),
                    StringComparison.OrdinalIgnoreCase)
                    .ShouldEqual(
                        true,
                        string.Format(
                            "Expected '{0}', not '{1}' for '{2}'.",
                            property.Value,
                            routeData.Values[property.Name], property.Name));
            }
        }

        public static void DoNotMap(this RouteCollection routes, string httpVerb, string url)
        {
            RetrieveRouteData(routes, httpVerb, url)
                .ShouldEqual((RouteData)null, "Should not find a route");
        }

        private static RouteData RetrieveRouteData(RouteCollection routes, string httpVerb, string url)
        {
            var httpContext = new Mock<HttpContextBase>();
            httpContext.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath).Returns(url);
            httpContext.Setup(c => c.Request.HttpMethod).Returns(httpVerb);

            return routes.GetRouteData(httpContext.Object);
        }

        private static IEnumerable<PropertyValue> GetProperties(object o)
        {
            return from prop in TypeDescriptor.GetProperties(o).Cast<PropertyDescriptor>()
                   let val = prop.GetValue(o)
                   where val != null
                   select new PropertyValue { Name = prop.Name, Value = val };
        }

        private sealed class PropertyValue
        {
            public string Name
            {
                get;
                set;
            }

            public object Value
            {
                get;
                set;
            }
        }
    }
}<commit_msg>Minor clean-up<commit_after>namespace Snittlistan.Test
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Web;
    using System.Web.Routing;
    using Moq;
    using MvcContrib.TestHelper;

    public static class RouteTestHelper
    {
        public static void Maps(this RouteCollection routes, string httpVerb, string url, object expectations)
        {
            var routeData = RetrieveRouteData(routes, httpVerb, url);
            routeData.ShouldNotBeNull("Should have found the route");

            foreach (var property in GetProperties(expectations))
            {
                var equal = string.Equals(
                    property.Value.ToString(),
                    routeData.Values[property.Name].ToString(),
                    StringComparison.OrdinalIgnoreCase);
                var message = string.Format("Expected '{0}', not '{1}' for '{2}'.", property.Value, routeData.Values[property.Name], property.Name);
                equal.ShouldEqual(true, message);
            }
        }

        public static void DoNotMap(this RouteCollection routes, string httpVerb, string url)
        {
            RetrieveRouteData(routes, httpVerb, url)
                .ShouldEqual((RouteData)null, "Should not find a route");
        }

        private static RouteData RetrieveRouteData(RouteCollection routes, string httpVerb, string url)
        {
            var httpContext = new Mock<HttpContextBase>();
            httpContext.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath).Returns(url);
            httpContext.Setup(c => c.Request.HttpMethod).Returns(httpVerb);

            return routes.GetRouteData(httpContext.Object);
        }

        private static IEnumerable<PropertyValue> GetProperties(object o)
        {
            return from prop in TypeDescriptor.GetProperties(o).Cast<PropertyDescriptor>()
                   let val = prop.GetValue(o)
                   where val != null
                   select new PropertyValue { Name = prop.Name, Value = val };
        }

        private sealed class PropertyValue
        {
            public string Name
            {
                get;
                set;
            }

            public object Value
            {
                get;
                set;
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07913813934756343, 'fraction_numerical': 0.0012082158679017317, 'mean_word_length': 1.5816008316008316, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '2213395', 'n_tokens_mistral': 1205, 'n_tokens_neox': 1134, 'n_words': 284}