Skip to content

Commit

Permalink
Lucene.Net.TestFramework.Util.LuceneTestCase: Cache codecType and sim…
Browse files Browse the repository at this point in the history
…ilarityName as strings so they don't have to be regenerated on each test (#261, #295)
  • Loading branch information
NightOwl888 committed Jun 30, 2020
1 parent 98c0295 commit 793fea9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,12 @@ private static IList<string> LoadCoreDirectories()
// 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>
Expand All @@ -671,11 +677,11 @@ public virtual void SetUp()
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>
Expand Down Expand Up @@ -736,6 +742,9 @@ public static void BeforeClass(Microsoft.VisualStudio.TestTools.UnitTesting.Test

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
Expand Down Expand Up @@ -767,6 +776,10 @@ public virtual void BeforeClass()
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)
{
Expand Down

0 comments on commit 793fea9

Please sign in to comment.