Skip to content

Commit

Permalink
fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Shazwazza committed Sep 8, 2022
1 parent 3516bba commit 07d0889
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions src/Examine.Test/Examine.Lucene/Search/AnalyzerTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System;
using System.Linq;
using System.Text;
using Examine.Lucene.Analyzers;
using Examine.Lucene.Providers;
using NUnit.Framework;
Expand All @@ -18,7 +21,7 @@ public void Given_CultureInvariantWhitespaceAnalyzer_When_SearchingBothCharVaria
ValueSet.FromObject(1.ToString(), "content",
new { bodyText = "Something rød something"}),
ValueSet.FromObject(2.ToString(), "content",
new { nodeName = "Something rod something"})
new { bodyText = "Something rod something"})
});

var searcher = (BaseLuceneSearcher)indexer.Searcher;
Expand All @@ -31,9 +34,13 @@ public void Given_CultureInvariantWhitespaceAnalyzer_When_SearchingBothCharVaria
var query2 = searcher
.CreateQuery("content")
.Field("bodyText", "rød");
var results2 = query1.Execute();
var results2 = query2.Execute();

Assert.AreEqual(1, results1.TotalItemCount);
Assert.AreEqual(2, results1.TotalItemCount);
DebugResults(results1);

Assert.AreEqual(2, results2.TotalItemCount);
DebugResults(results2);
}
}

Expand All @@ -48,7 +55,7 @@ public void Given_CultureInvariantStandardAnalyzer_When_SearchingBothCharVariant
ValueSet.FromObject(1.ToString(), "content",
new { bodyText = "Something rød something"}),
ValueSet.FromObject(2.ToString(), "content",
new { nodeName = "Something rod something"})
new { bodyText = "Something rod something"})
});

var searcher = (BaseLuceneSearcher)indexer.Searcher;
Expand All @@ -61,9 +68,35 @@ public void Given_CultureInvariantStandardAnalyzer_When_SearchingBothCharVariant
var query2 = searcher
.CreateQuery("content")
.Field("bodyText", "rød");
var results2 = query1.Execute();
var results2 = query2.Execute();

Assert.AreEqual(2, results1.TotalItemCount);
DebugResults(results1);

Assert.AreEqual(1, results1.TotalItemCount);
Assert.AreEqual(2, results2.TotalItemCount);
DebugResults(results2);
}
}

private void DebugResults(ISearchResults results)
{
foreach(var r in results)
{
var sb = new StringBuilder();
sb.Append("Id = ");
sb.Append(r.Id);
sb.Append(", Values = ");
foreach(var vals in r.AllValues)
{
sb.Append(vals.Key);
sb.Append(" = ");
foreach(var val in vals.Value)
{
sb.Append(val);
sb.Append(", ");
}
}
Console.WriteLine(sb.ToString());
}
}
}
Expand Down

0 comments on commit 07d0889

Please sign in to comment.