<commit_before>using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using N2.Details;
using N2.Persistence;
using N2.Persistence.NH;
using N2.Tests.Persistence.Definitions;
using NUnit.Framework;
using Shouldly;

namespace N2.Tests.Persistence.NH
{
	[TestFixture, Category("Integration")]
	public class ItemRepositoryTests_Finds : DatabasePreparingBase
	{
		ContentItemRepository repository;
		new ISessionProvider sessionProvider;
		private PersistableItem1 root;
		private PersistableItem1 child1;
		private PersistableItem1 grandchild1;
		private PersistableItem1 child2;
		private PersistablePart1 part1;
		private PersistablePart1 part2;
		private PersistableItem1 version;
		private ContentItem[] all;

		[SetUp]
		public override void SetUp()
		{
			base.SetUp();
			CreateDatabaseSchema();

			sessionProvider = engine.Resolve<ISessionProvider>();
			repository = new ContentItemRepository(sessionProvider);

			all = new ContentItem []
			{
				root = CreateOneItem<Definitions.PersistableItem1>(0, "page", null),
				child1 = CreateOneItem<Definitions.PersistableItem1>(0, "page1", root),
				grandchild1 = CreateOneItem<Definitions.PersistableItem1>(0, "page1_1", child1),
				part1 = CreateOneItem<Definitions.PersistablePart1>(0, "part1", child1),
				part2 = CreateOneItem<Definitions.PersistablePart1>(0, "part1", child1),
				child2 = CreateOneItem<Definitions.PersistableItem1>(0, "page2", root),
				version = CreateOneItem<Definitions.PersistableItem1>(0, "page1", null)
			};
			part1.ZoneName = "Left";
			part2.ZoneName = "RecursiveLeft";
			child1["Hello"] = "World";
			grandchild1["Age"] = 1.7;

			repository.SaveOrUpdate(root);

			version.VersionOf = child1;
			repository.SaveOrUpdate(version);
		}

		[Test]
		public void Find_ByID_Equals()
		{
			repository.Find(Parameter.Equal("ID", grandchild1.ID)).Single().ShouldBe(grandchild1);
		}

		[Test]
		public void Find_ByID_NotEquals()
		{
			repository.Find(Parameter.NotEqual("ID", grandchild1.ID)).Count().ShouldBe(all.Length - 1);
		}

		[Test]
		public void Find_ByID_GreaterThan()
		{
			repository.Find(Parameter.GreaterThan("ID", grandchild1.ID)).SequenceEqual(all.Where(i => i.ID > grandchild1.ID));
		}
<commit_msg>Fixed some item finder tests<commit_after>using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using N2.Details;
using N2.Persistence;
using N2.Persistence.NH;
using N2.Tests.Persistence.Definitions;
using NUnit.Framework;
using Shouldly;

namespace N2.Tests.Persistence.NH
{
	[TestFixture, Category("Integration")]
	public class ItemRepositoryTests_Finds : DatabasePreparingBase
	{
		ContentItemRepository repository;
		new ISessionProvider sessionProvider;
		private PersistableItem1 root;
		private PersistableItem1 child1;
		private PersistableItem1 grandchild1;
		private PersistableItem1 child2;
		private PersistablePart1 part1;
		private PersistablePart1 part2;
		private PersistableItem1 version;
		private ContentItem[] all;

		[SetUp]
		public override void SetUp()
		{
			base.SetUp();
			CreateDatabaseSchema();

			sessionProvider = engine.Resolve<ISessionProvider>();
			repository = new ContentItemRepository(sessionProvider);

			all = new ContentItem []
			{
				root = CreateOneItem<Definitions.PersistableItem1>(0, "page", null),
				child1 = CreateOneItem<Definitions.PersistableItem1>(0, "page1", root),
				grandchild1 = CreateOneItem<Definitions.PersistableItem1>(0, "page1_1", child1),
				part1 = CreateOneItem<Definitions.PersistablePart1>(0, "part1", child1),
				part2 = CreateOneItem<Definitions.PersistablePart1>(0, "part1", child1),
				child2 = CreateOneItem<Definitions.PersistableItem1>(0, "page2", root),
				version = CreateOneItem<Definitions.PersistableItem1>(0, "page1", null)
			};
			part1.ZoneName = "Left";
			part2.ZoneName = "RecursiveLeft";
			child1["Hello"] = "World";
			grandchild1["Age"] = 1.7;

			version.VersionOf = child1;
            foreach (var item in all)
                repository.SaveOrUpdate(all);
		}

		[Test]
		public void Find_ByID_Equals()
		{
			repository.Find(Parameter.Equal("ID", grandchild1.ID)).Single().ShouldBe(grandchild1);
		}

		[Test]
		public void Find_ByID_NotEquals()
		{
			repository.Find(Parameter.NotEqual("ID", grandchild1.ID)).Count().ShouldBe(all.Length - 1);
		}

		[Test]
		public void Find_ByID_GreaterThan()
		{
			repository.Find(Parameter.GreaterThan("ID", grandchild1.ID)).SequenceEqual(all.Where(i => i.ID > grandchild1.ID));
		}

{'fraction_non_alphanumeric': 0.11856474258970359, 'fraction_numerical': 0.026298194784934253, 'mean_word_length': 5.073071718538565, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '4247679', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1439, 'n_words': 270}