<commit_before>﻿#if NET40Plus
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
using System.Web.Mvc;

namespace Navigation.Test.Mvc
{
	[TestClass]
	public class LinkExtensionsTest
	{
		private static HtmlHelper HtmlHelper
		{
			get
			{
				ViewContext context = new Mock<ViewContext>().Object;
				IViewDataContainer container = new Mock<IViewDataContainer>().Object;
				return new HtmlHelper(context, container);
			}
		}

		[TestMethod]
		public void NavigationLinkTest()
		{
			Assert.AreEqual("<a href=\"/r0\">link</a>", HtmlHelper.NavigationLink("link", "d7").ToHtmlString());
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void NavigationLinkNullTextTest()
		{
			HtmlHelper.NavigationLink(null, "d7");
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void NavigationLinkBlankTextTest()
		{
			HtmlHelper.NavigationLink("", "d7");
		}

		[TestMethod]
		public void NavigationLinkTextEncodedTest()
		{
			Assert.AreEqual("<a href=\"/r0\">link&lt;</a>", HtmlHelper.NavigationLink("link<", "d7").ToHtmlString());
		}

		[TestMethod]
		public void NavigationLinkDataTest()
		{
			StateController.Navigate("d7");
			Assert.AreEqual("<a href=\"/r1?a=1\">link</a>", HtmlHelper.NavigationLink("link", "t0", 
				new NavigationData { { "a", "1" } }).ToHtmlString());
		}

		[TestMethod]
		public void NavigationLinkAttributesTest()
		{
			Assert.AreEqual("<a href=\"/r0\" title=\"details\">link</a>", HtmlHelper.NavigationLink("link", "d7", 
				new { title = "details" }).ToHtmlString());
		}

		[TestMethod]
		public void NavigationLinkDataAndAttributesTest()
		{
			Assert.AreEqual("<a href=\"/r0?a=1\" title=\"details\">link</a>", HtmlHelper.NavigationLink("link", "d7", 
				new NavigationData { { "a", "1" } }, new { title = "details" }).ToHtmlString());
		}

		[TestMethod]
		public void NavigationBackLinkTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			StateController.Navigate("t0");
			Assert.AreEqual("<a href=\"/r1\">link</a>", HtmlHelper.NavigationBackLink("link", 1).ToHtmlString());
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void NavigationBackLinkBlankTextTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			StateController.Navigate("t0");
			HtmlHelper.NavigationBackLink("", 1);
		}

		[TestMethod]
		public void NavigationBackLinkAttributesTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			StateController.Navigate("t0");
			Assert.AreEqual("<a href=\"/r1\" title=\"details\">link</a>", HtmlHelper.NavigationBackLink("link", 1,
				new { title = "details" }).ToHtmlString());
		}

		[TestMethod]
		public void RefreshLinkTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"refresh\" href=\"/r1\">link</a>", HtmlHelper.RefreshLink("link").ToHtmlString());
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void RefreshLinkBlankTetTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			HtmlHelper.RefreshLink(null);
		}

		[TestMethod]
		public void RefreshLinkDataTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"refresh\" href=\"/r1?a=1\">link</a>", HtmlHelper.RefreshLink("link",
				new NavigationData { { "a", "1" } }).ToHtmlString());
		}

		[TestMethod]
		public void RefreshLinkAttributesTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"refresh\" href=\"/r1\" title=\"details\">link</a>", HtmlHelper.RefreshLink("link",
				new { title = "details" }).ToHtmlString());
		}

		[TestMethod]
		public void RefreshLinkNavigationDataAttributeTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"noajax\" href=\"/r1\">link</a>", HtmlHelper.RefreshLink("link",
				new { data_navigation = "noajax" }).ToHtmlString());
		}

		[TestMethod]
		public void RefreshLinkDataAndAttributesTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"refresh\" href=\"/r1?a=1\" title=\"details\">link</a>", HtmlHelper.RefreshLink("link",
				new NavigationData { { "a", "1" } }, false, new { title = "details" }).ToHtmlString());
		}

		[TestMethod]
		public void RefreshLinkDataAndNavigationDataAttributeTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"noajax\" href=\"/r1?a=1\">link</a>", HtmlHelper.RefreshLink("link",
				new NavigationData { { "a", "1" } }, false, new { data_navigation = "noajax" }).ToHtmlString());
		}
	}
}
#endif<commit_msg>Added include current data refresh link test<commit_after>﻿#if NET40Plus
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
using System.Web.Mvc;

namespace Navigation.Test.Mvc
{
	[TestClass]
	public class LinkExtensionsTest
	{
		private static HtmlHelper HtmlHelper
		{
			get
			{
				ViewContext context = new Mock<ViewContext>().Object;
				IViewDataContainer container = new Mock<IViewDataContainer>().Object;
				return new HtmlHelper(context, container);
			}
		}

		[TestMethod]
		public void NavigationLinkTest()
		{
			Assert.AreEqual("<a href=\"/r0\">link</a>", HtmlHelper.NavigationLink("link", "d7").ToHtmlString());
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void NavigationLinkNullTextTest()
		{
			HtmlHelper.NavigationLink(null, "d7");
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void NavigationLinkBlankTextTest()
		{
			HtmlHelper.NavigationLink("", "d7");
		}

		[TestMethod]
		public void NavigationLinkTextEncodedTest()
		{
			Assert.AreEqual("<a href=\"/r0\">link&lt;</a>", HtmlHelper.NavigationLink("link<", "d7").ToHtmlString());
		}

		[TestMethod]
		public void NavigationLinkDataTest()
		{
			StateController.Navigate("d7");
			Assert.AreEqual("<a href=\"/r1?a=1\">link</a>", HtmlHelper.NavigationLink("link", "t0", 
				new NavigationData { { "a", "1" } }).ToHtmlString());
		}

		[TestMethod]
		public void NavigationLinkAttributesTest()
		{
			Assert.AreEqual("<a href=\"/r0\" title=\"details\">link</a>", HtmlHelper.NavigationLink("link", "d7", 
				new { title = "details" }).ToHtmlString());
		}

		[TestMethod]
		public void NavigationLinkDataAndAttributesTest()
		{
			Assert.AreEqual("<a href=\"/r0?a=1\" title=\"details\">link</a>", HtmlHelper.NavigationLink("link", "d7", 
				new NavigationData { { "a", "1" } }, new { title = "details" }).ToHtmlString());
		}

		[TestMethod]
		public void NavigationBackLinkTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			StateController.Navigate("t0");
			Assert.AreEqual("<a href=\"/r1\">link</a>", HtmlHelper.NavigationBackLink("link", 1).ToHtmlString());
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void NavigationBackLinkBlankTextTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			StateController.Navigate("t0");
			HtmlHelper.NavigationBackLink("", 1);
		}

		[TestMethod]
		public void NavigationBackLinkAttributesTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			StateController.Navigate("t0");
			Assert.AreEqual("<a href=\"/r1\" title=\"details\">link</a>", HtmlHelper.NavigationBackLink("link", 1,
				new { title = "details" }).ToHtmlString());
		}

		[TestMethod]
		public void RefreshLinkTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"refresh\" href=\"/r1\">link</a>", HtmlHelper.RefreshLink("link").ToHtmlString());
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void RefreshLinkBlankTetTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			HtmlHelper.RefreshLink(null);
		}

		[TestMethod]
		public void RefreshLinkDataTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"refresh\" href=\"/r1?a=1\">link</a>", HtmlHelper.RefreshLink("link",
				new NavigationData { { "a", "1" } }).ToHtmlString());
		}

		[TestMethod]
		public void RefreshLinkAttributesTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"refresh\" href=\"/r1\" title=\"details\">link</a>", HtmlHelper.RefreshLink("link",
				new { title = "details" }).ToHtmlString());
		}

		[TestMethod]
		public void RefreshLinkNavigationDataAttributeTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"noajax\" href=\"/r1\">link</a>", HtmlHelper.RefreshLink("link",
				new { data_navigation = "noajax" }).ToHtmlString());
		}

		[TestMethod]
		public void RefreshLinkDataAndAttributesTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"refresh\" href=\"/r1?a=1\" title=\"details\">link</a>", HtmlHelper.RefreshLink("link",
				new NavigationData { { "a", "1" } }, false, new { title = "details" }).ToHtmlString());
		}

		[TestMethod]
		public void RefreshLinkDataAndNavigationDataAttributeTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0");
			Assert.AreEqual("<a data-navigation=\"noajax\" href=\"/r1?a=1\">link</a>", HtmlHelper.RefreshLink("link",
				new NavigationData { { "a", "1" } }, false, new { data_navigation = "noajax" }).ToHtmlString());
		}

		[TestMethod]
		public void RefreshLinkIncludeCurrentDataTest()
		{
			StateController.Navigate("d7");
			StateController.Navigate("t0", new NavigationData { { "b", "0" } });
			Assert.AreEqual("<a data-include-current=\"true\" data-navigation=\"refresh\" href=\"/r1?b=0&amp;a=1\">link</a>", 
				HtmlHelper.RefreshLink("link", new NavigationData { { "a", "1" } }, true).ToHtmlString());
		}
	}
}
#endif
{'fraction_non_alphanumeric': 0.178743961352657, 'fraction_numerical': 0.012323770087745243, 'mean_word_length': 4.829885057471264, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 61, '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': '1547640', 'n_tokens_mistral': 3740, 'n_tokens_neox': 3272, 'n_words': 517}