Skip to content

Commit

Permalink
RavenDB-21995 Refactored test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lwiel authored and arekpalinski committed Jan 31, 2024
1 parent 4b96bc6 commit b0a16f8
Showing 1 changed file with 10 additions and 43 deletions.
53 changes: 10 additions & 43 deletions test/SlowTests/Issues/RavenDB_21995.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,29 @@ public async Task TestWildcardAsSearchTerm(Options options)

await session.SaveChangesAsync();

var luceneIndex = new LuceneIndex();
var coraxIndex = new CoraxIndex();
var dummyIndex = new DummyIndex();

await luceneIndex.ExecuteAsync(store);
await coraxIndex.ExecuteAsync(store);
await dummyIndex.ExecuteAsync(store);

await Indexes.WaitForIndexingAsync(store);

var userListLucene = await session.Query<Customer>(luceneIndex.IndexName)
var userList = await session.Query<Customer>(dummyIndex.IndexName)
.Search(x => x.Name, "*")
.ToListAsync();

var userListCorax = await session.Query<Customer>(coraxIndex.IndexName)
.Search(x => x.Name, "*")
.ToListAsync();

Assert.Equal(2, userListLucene.Count);
Assert.Equal(2, userListCorax.Count);

var userListLuceneDoubleWildcard = await session.Query<Customer>(luceneIndex.IndexName)
.Search(x => x.Name, "**")
.ToListAsync();
Assert.Equal(2, userList.Count);

var userListCoraxDoubleWildcard = await session.Query<Customer>(coraxIndex.IndexName)
var userListDoubleWildcard = await session.Query<Customer>(dummyIndex.IndexName)
.Search(x => x.Name, "**")
.ToListAsync();

Assert.Equal(2, userListLuceneDoubleWildcard.Count);
Assert.Equal(2, userListCoraxDoubleWildcard.Count);
Assert.Equal(2, userListDoubleWildcard.Count);

var userListLuceneTripleWildcard = await session.Query<Customer>(luceneIndex.IndexName)
var userListTripleWildcard = await session.Query<Customer>(dummyIndex.IndexName)
.Search(x => x.Name, "***")
.ToListAsync();

var userListCoraxTripleWildcard = await session.Query<Customer>(coraxIndex.IndexName)
.Search(x => x.Name, "***")
.ToListAsync();

Assert.Equal(2, userListLuceneTripleWildcard.Count);
Assert.Equal(2, userListCoraxTripleWildcard.Count);
Assert.Equal(2, userListTripleWildcard.Count);
}
}
}
Expand All @@ -80,24 +63,9 @@ private class Customer
public string Name { get; set; }
}

private class LuceneIndex : AbstractIndexCreationTask<Customer>
{
public LuceneIndex()
{
Map = customers => from customer in customers
select new
{
customer.Name
};

Index(x => x.Name, FieldIndexing.Search);
SearchEngineType = Raven.Client.Documents.Indexes.SearchEngineType.Lucene;
}
}

private class CoraxIndex : AbstractIndexCreationTask<Customer>
private class DummyIndex : AbstractIndexCreationTask<Customer>
{
public CoraxIndex()
public DummyIndex()
{
Map = customers => from customer in customers
select new
Expand All @@ -106,7 +74,6 @@ public CoraxIndex()
};

Index(x => x.Name, FieldIndexing.Search);
SearchEngineType = Raven.Client.Documents.Indexes.SearchEngineType.Corax;
}
}
}

0 comments on commit b0a16f8

Please sign in to comment.