<commit_before>// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Castle.MonoRail.Framework.Tests.Routing
{
	using Framework.Routing;
	using NUnit.Framework;

	[TestFixture]
	public class PatternRouteTestCase : BaseRuleTestFixture
	{
		[Test]
		public void ShouldMatchStatic()
		{
			PatternRoute route = new PatternRoute("/some/path");
			RouteMatch match = new RouteMatch();
			Assert.AreEqual(4, route.Matches("/some/path", CreateGetContext(), match)); 
		}

		[Test]
		public void ShouldMatchStaticWithFileExtension()
		{
			PatternRoute route = new PatternRoute("/default.aspx");
			RouteMatch match = new RouteMatch();
			Assert.AreEqual(4, route.Matches("/default.aspx", CreateGetContext(), match));
		}

		[Test]
		public void ShouldMatchStaticCaseInsensitive()
		{
			PatternRoute route = new PatternRoute("/default.aspx");
			RouteMatch match = new RouteMatch();
			Assert.AreEqual(4, route.Matches("/DEFAULT.ASPX", CreateGetContext(), match));

			route = new PatternRoute("/some/path");
			match = new RouteMatch();
			Assert.AreEqual(4, route.Matches("/SOME/Path", CreateGetContext(), match));
		}

		[Test]
		public void ShouldMatchHiphensAndUnderlines()
		{
			PatternRoute route = new PatternRoute("/some/path_to-this");
			RouteMatch match = new RouteMatch();
			Assert.AreEqual(4, route.Matches("/some/path_to-this", CreateGetContext(), match)); 
		}

		[Test]
		public void NamedRequiredParameters()
		{
			PatternRoute route = new PatternRoute("/<controller>/<action>");
			RouteMatch match = new RouteMatch();
			Assert.AreEqual(4, route.Matches("/some/act", CreateGetContext(), match));
			Assert.AreEqual("some", match.Parameters["controller"]);
			Assert.AreEqual("act", match.Parameters["action"]);
		}

		[Test]
		public void NamedRequiredParametersForExtension()
		{
			PatternRoute route = new PatternRoute("/<controller>/<action>.<format>");
			RouteMatch match = new RouteMatch();<commit_msg>Tests are passing again<commit_after>// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Castle.MonoRail.Framework.Tests.Routing
{
	using Framework.Routing;
	using NUnit.Framework;

	[TestFixture]
	public class PatternRouteTestCase : BaseRuleTestFixture
	{
		[Test]
		public void ShouldMatchStatic()
		{
			PatternRoute route = new PatternRoute("/some/path");
			RouteMatch match = new RouteMatch();
			Assert.AreEqual(8, route.Matches("/some/path", CreateGetContext(), match)); 
		}

		[Test]
		public void ShouldMatchStaticWithFileExtension()
		{
			PatternRoute route = new PatternRoute("/default.aspx");
			RouteMatch match = new RouteMatch();
			Assert.AreEqual(8, route.Matches("/default.aspx", CreateGetContext(), match));
		}

		[Test]
		public void ShouldMatchStaticCaseInsensitive()
		{
			PatternRoute route = new PatternRoute("/default.aspx");
			RouteMatch match = new RouteMatch();
			Assert.AreEqual(8, route.Matches("/DEFAULT.ASPX", CreateGetContext(), match));

			route = new PatternRoute("/some/path");
			match = new RouteMatch();
			Assert.AreEqual(8, route.Matches("/SOME/Path", CreateGetContext(), match));
		}

		[Test]
		public void ShouldMatchHiphensAndUnderlines()
		{
			PatternRoute route = new PatternRoute("/some/path_to-this");
			RouteMatch match = new RouteMatch();
			Assert.AreEqual(8, route.Matches("/some/path_to-this", CreateGetContext(), match)); 
		}

		[Test]
		public void NamedRequiredParameters()
		{
			PatternRoute route = new PatternRoute("/<controller>/<action>");
			RouteMatch match = new RouteMatch();
			Assert.AreEqual(4, route.Matches("/some/act", CreateGetContext(), match));
			Assert.AreEqual("some", match.Parameters["controller"]);
			Assert.AreEqual("act", match.Parameters["action"]);
		}

		[Test]
		public void NamedRequiredParametersForExtension()
		{
			PatternRoute route = new PatternRoute("/<controller>/<action>.<format>");
			RouteMatch match = new RouteMatch();
{'fraction_non_alphanumeric': 0.12946783161239078, 'fraction_numerical': 0.007148530579825258, 'mean_word_length': 4.324524312896406, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6817902', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1403, 'n_words': 404}