<commit_before>﻿using System;
using System.Net.Http;
using System.Web.Mvc;
using System.Web.Routing;

using MvcRouteTester.ApiRoute;
using MvcRouteTester.Assertions;
using MvcRouteTester.Common;
using MvcRouteTester.HttpMocking;

namespace MvcRouteTester.WebRoute
{
	internal static class WebRouteAssert
	{
		internal static void HasRoute(RouteCollection routes, string url)
		{
			var pathUrl = UrlHelpers.PrependTilde(url);

			var httpContext = HttpMockery.ContextForUrl(pathUrl);
			var routeData = routes.GetRouteData(httpContext);

			if (routeData == null)
			{
				var message = string.Format("Should have found the route to '{0}'", url);
				Asserts.Fail(message);
			}
		}

		internal static void HasRoute(RouteCollection routes, HttpMethod method, string url, string body, BodyFormat bodyFormat, RouteValues expectedProps)
		{
			var pathUrl = UrlHelpers.PrependTilde(url);
			var httpContext = HttpMockery.ContextForUrl(method, pathUrl, body);
			var routeData = routes.GetRouteData(httpContext);

			if (routeData == null)
			{<commit_msg>#37 Amended WebRouteAssert to filter RouteData<commit_after>﻿using System;
using System.Net.Http;
using System.Web.Mvc;
using System.Web.Routing;

using MvcRouteTester.ApiRoute;
using MvcRouteTester.Assertions;
using MvcRouteTester.Common;
using MvcRouteTester.HttpMocking;

namespace MvcRouteTester.WebRoute
{
	internal static class WebRouteAssert
	{
		internal static void HasRoute(RouteCollection routes, string url)
		{
			var pathUrl = UrlHelpers.PrependTilde(url);

			var httpContext = HttpMockery.ContextForUrl(pathUrl);
			var routeData = routes.GetRouteData(httpContext);

			if (routeData == null)
			{
				var message = string.Format("Should have found the route to '{0}'", url);
				Asserts.Fail(message);
			}
		}

		internal static void HasRoute(RouteCollection routes, HttpMethod method, string url, string body, BodyFormat bodyFormat, RouteValues expectedProps)
		{
			var pathUrl = UrlHelpers.PrependTilde(url);
			var httpContext = HttpMockery.ContextForUrl(method, pathUrl, body);
			var routeData = routes.GetRouteData(httpContext);

            if (routeData != null)
            {
                routeData = DirectRouteHelper.FilterRouteData(routeData, httpContext);
            }

			if (routeData == null)
			{
{'fraction_non_alphanumeric': 0.09047202797202797, 'fraction_numerical': 0.0017482517482517483, 'mean_word_length': 4.45, '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': '925154', 'n_tokens_mistral': 762, 'n_tokens_neox': 691, 'n_words': 173}