<commit_before>﻿using N2.Engine;
using N2.Security;
using N2.Tests.Fakes;
using NUnit.Framework;
using N2.Collections;

namespace N2.Extensions.Tests.Extensions
{
	[TestFixture]
	public class FilterExtensionsTests : ExtensionTests
	{
		Function<ISecurityManager> backup;

		[TestFixtureSetUp]
		public void TestFixtureSetUp()
		{
			backup = AccessFilter.CurrentSecurityManager;
			FakeSecurityManager securityManager = new FakeSecurityManager();
			AccessFilter.CurrentSecurityManager = () => securityManager;
		}
		[TestFixtureTearDown]
		public void TestFixtureTearDown()
		{
			AccessFilter.CurrentSecurityManager = backup;
		}



		[Test]
		public void DoenstFilter_AccessibleItem()
		{
			var item = CreateOneItem<MyItem>(3, "item", root);

			var filteredItem = item.FilterByAccess();

			Assert.That(filteredItem, Is.SameAs(item));
		}

		[Test]
		public void Filters_UnaccessibleItem()
		{
			var item = CreateOneItem<MyItem>(3, "item", root);
			item["Unaccessible"] = true;

			var filteredItem = item.FilterByAccess();

			Assert.That(filteredItem, Is.Null);
		}



		[Test]
		public void DoesntFilter_VisibleItem()
		{
			var item = CreateOneItem<MyItem>(3, "item", root);

			var filteredItem = item.FilterByNavigation();
<commit_msg>null test<commit_after>﻿using N2.Engine;
using N2.Security;
using N2.Tests.Fakes;
using NUnit.Framework;
using N2.Collections;

namespace N2.Extensions.Tests.Extensions
{
	[TestFixture]
	public class FilterExtensionsTests : ExtensionTests
	{
		Function<ISecurityManager> backup;

		[TestFixtureSetUp]
		public void TestFixtureSetUp()
		{
			backup = AccessFilter.CurrentSecurityManager;
			FakeSecurityManager securityManager = new FakeSecurityManager();
			AccessFilter.CurrentSecurityManager = () => securityManager;
		}
		[TestFixtureTearDown]
		public void TestFixtureTearDown()
		{
			AccessFilter.CurrentSecurityManager = backup;
		}



		[Test]
		public void DoenstFilter_AccessibleItem()
		{
			var item = CreateOneItem<MyItem>(3, "item", root);

			var filteredItem = item.FilterByAccess();

			Assert.That(filteredItem, Is.SameAs(item));
		}

		[Test]
		public void IgnoresNull()
		{
			MyItem item = null;

			var filteredItem = item.FilterByAccess();

			Assert.That(filteredItem, Is.Null);
		}

		[Test]
		public void Filters_UnaccessibleItem()
		{
			var item = CreateOneItem<MyItem>(3, "item", root);
			item["Unaccessible"] = true;

			var filteredItem = item.FilterByAccess();

			Assert.That(filteredItem, Is.Null);
		}



		[Test]
		public void DoesntFilter_VisibleItem()
		{
			var item = CreateOneItem<MyItem>(3, "item", root);

			var filteredItem = item.FilterByNavigation();

{'fraction_non_alphanumeric': 0.1106913486966377, 'fraction_numerical': 0.006044578768417076, 'mean_word_length': 4.528183716075157, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1370056', 'n_tokens_mistral': 976, 'n_tokens_neox': 837, 'n_words': 171}