<commit_before>﻿using NUnit.Framework;
using SocialToolBox.Core.Database;
using SocialToolBox.Core.Database.Index;
using SocialToolBox.Core.Mocks.Database;
using SocialToolBox.Core.Mocks.Database.Projections;

namespace SocialToolBox.Core.Tests.Database.Projection
{
    [TestFixture]
    public class in_memory_index
    {
        public readonly Id IdA = Id.Parse("aaaaaaaaaaa");
        public readonly Id IdB = Id.Parse("bbbbbbbbbbb");
        public InMemoryIndex<StringKey, StringKey> Index;
        public IProjectCursor Cursor;

        [SetUp]
        public void SetUp()
        {
            var driver = new DatabaseDriver();
            Index = new InMemoryIndex<StringKey, StringKey>();
            Cursor = driver.OpenProjectionCursor();
        }

        public StringKey K(string k) { return new StringKey(k); }

        [Test]
        public void default_is_empty()
        {
            Assert.AreEqual(0, Index.Count(K("A"), Cursor).Result);
        }
    }
}<commit_msg>Ensure that counting one element works<commit_after>﻿using NUnit.Framework;
using SocialToolBox.Core.Database;
using SocialToolBox.Core.Database.Index;
using SocialToolBox.Core.Mocks.Database;
using SocialToolBox.Core.Mocks.Database.Projections;

namespace SocialToolBox.Core.Tests.Database.Projection
{
    [TestFixture]
    public class in_memory_index
    {
        public readonly Id IdA = Id.Parse("aaaaaaaaaaa");
        public readonly Id IdB = Id.Parse("bbbbbbbbbbb");
        public InMemoryIndex<StringKey, StringKey> Index;
        public IProjectCursor Cursor;

        [SetUp]
        public void SetUp()
        {
            var driver = new DatabaseDriver();
            Index = new InMemoryIndex<StringKey, StringKey>();
            Cursor = driver.OpenProjectionCursor();
        }

        public StringKey K(string k) { return new StringKey(k); }

        [Test]
        public void default_is_empty()
        {
            Assert.AreEqual(0, Index.Count(K("A"), Cursor).Result);
        }

        [Test]
        public void count_one_is_correct()
        {
            Index.Add(IdA, K("A"), K("B"), Cursor).Wait();
            Assert.AreEqual(1, Index.Count(K("A"), Cursor).Result);
            Assert.AreEqual(0, Index.Count(K("B"), Cursor).Result);
        }
    }
}
{'fraction_non_alphanumeric': 0.11038107752956636, 'fraction_numerical': 0.0017520805957074025, 'mean_word_length': 2.5743348982785603, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '5627980', 'n_tokens_mistral': 669, 'n_tokens_neox': 657, 'n_words': 141}