You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2020/06/30 21:50:50 UTC
[lucenenet] 14/27: Lucene.Net.TestFramework.Util.LuceneTestCase:
Cache codecType and similarityName as strings so they don't have to be
regenerated on each test (#261, #295)
This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit 793fea9e40e00f7410421d2054a83432d92ac8df
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Mon Jun 29 08:39:45 2020 +0700
Lucene.Net.TestFramework.Util.LuceneTestCase: Cache codecType and similarityName as strings so they don't have to be regenerated on each test (#261, #295)
---
src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
index 816f191..854da97 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -648,6 +648,12 @@ namespace Lucene.Net.Util
// Suite and test case setup/ cleanup.
// -----------------------------------------------------------------
+ // LUCENENET specific: Temporary storage for random selections so they
+ // can be set once per OneTimeSetUp and reused multiple times in SetUp
+ // where they are written to the output.
+ private string codecType;
+ private string similarityName;
+
/// <summary>
/// For subclasses to override. Overrides must call <c>base.SetUp()</c>.
/// </summary>
@@ -671,11 +677,11 @@ namespace Lucene.Net.Util
Console.Write("Default Codec: ");
Console.Write(ClassEnvRule.codec.Name);
Console.Write(" (");
- Console.Write(ClassEnvRule.codec.GetType().ToString());
+ Console.Write(codecType);
Console.WriteLine(")");
Console.Write("Default Similarity: ");
- Console.WriteLine(ClassEnvRule.similarity.ToString());
+ Console.WriteLine(similarityName);
}
/// <summary>
@@ -736,6 +742,9 @@ namespace Lucene.Net.Util
ClassEnvRule.Before(null);
+ // LUCENENET: Generate the info once so it can be printed out for each test
+ codecType = ClassEnvRule.codec.GetType().Name;
+ similarityName = ClassEnvRule.similarity.ToString();
// LUCENENET TODO: Scan for a custom attribute and setup ordering to
// initialize data from this class to the top class
@@ -767,6 +776,10 @@ namespace Lucene.Net.Util
LuceneTestFrameworkInitializer.EnsureInitialized();
ClassEnvRule.Before(this);
+
+ // LUCENENET: Generate the info once so it can be printed out for each test
+ codecType = ClassEnvRule.codec.GetType().Name;
+ similarityName = ClassEnvRule.similarity.ToString();
}
catch (Exception ex)
{