Esempio n. 1
0
        public async Task AddTermsWithMultipleCommits_AllShouldBeFound()
        {
            _fix = new FieldIndex(RootIndexDir, "text");

            await _fix.AddTerm("term of document 1", 1);

            await _fix.AddTerm("another term of document 1", 1);

            await _fix.Commit();

            await _fix.AddTerm("term of document 2", 2);

            await _fix.AddTerm("another term of document 2", 2);

            await _fix.Commit();

            _fix.Search("term of document 1")
            .Should().BeEquivalentTo(new[] { 1 });
            _fix.Search("another term of document 1")
            .Should().BeEquivalentTo(new[] { 1 });
            _fix.Search("term of document 2")
            .Should().BeEquivalentTo(new[] { 2 });
            _fix.Search("another term of document 2")
            .Should().BeEquivalentTo(new[] { 2 });
        }
Esempio n. 2
0
        public async Task CommitEmptyIndex_ShouldNotThrowError()
        {
            _fix = new FieldIndex(RootIndexDir, "text");

            await _fix.Commit();

            _fix.Search("any text").Should().BeEmpty();
        }
Esempio n. 3
0
        public async Task QueryNonExistingTerm_ShouldGetEmptyResultSet()
        {
            _fix = new FieldIndex(RootIndexDir, "text");

            await _fix.AddTerm("term of document 1", 1);

            await _fix.Commit();

            _fix.Search("unknown term").Should().BeEmpty();
        }
Esempio n. 4
0
        public async Task AddedTermCanBeFoundByItsValue()
        {
            _fix = new FieldIndex(RootIndexDir, "text");

            await _fix.AddTerm("term of document 1", 1);

            await _fix.AddTerm("another term of document 1", 1);

            await _fix.AddTerm("term of document 2", 2);

            await _fix.AddTerm("another term of document 2", 2);

            await _fix.Commit();

            _fix.Search("term of document 1")
            .Should().BeEquivalentTo(new[] { 1 });
            _fix.Search("another term of document 1")
            .Should().BeEquivalentTo(new[] { 1 });
            _fix.Search("term of document 2")
            .Should().BeEquivalentTo(new[] { 2 });
            _fix.Search("another term of document 2")
            .Should().BeEquivalentTo(new[] { 2 });
        }