Class LuceneTestCase
Base class for all Lucene.Net unit tests.
Class and instance setup.
The preferred way to specify class (suite-level) setup/cleanup is to use
static methods annotated with NUnit.Framework.OneTimeSetUpAttribute and NUnit.Framework.OneTimeTearDownAttribute. Any
code in these methods is executed within the test framework's control and
ensure proper setup has been made. Try not to use static initializers
(including complex readonly field initializers). Static initializers are
executed before any setup rules are fired and may cause you (or somebody
else) headaches.
For instance-level setup, use NUnit.Framework.SetUpAttribute and NUnit.Framework.TearDownAttribute annotated
methods. If you override either SetUp() or TearDown() in
your subclass, make sure you call base.SetUp()
and
base.TearDown()
. This is detected and enforced.
Specifying test cases
Any test method annotated with NUnit.Framework.TestAttribute is considered a test case.
Randomized execution and test facilities
LuceneTestCase uses a custom LuceneTestCase.TestFixtureAttribute to execute test cases.
The custom LuceneTestCase.TestFixtureAttribute has built-in support for test randomization
including access to a repeatable Random instance. See
Random property. Any test using Random acquired from
Random should be fully reproducible (assuming no race conditions
between threads etc.). The initial seed for a test case is reported in the failure
test message.
The seed can be configured with a RunSettings file, a lucene.testSettings.config
JSON file,
an environment variable, or using RandomSeedAttribute at the assembly level.
It is recommended to configure the culture also, since they are randomly picked from a list
of cultures installed on a given machine, so the culture will vary from one machine to the next.
.runsettings File Configuration Example
<RunSettings>
<TestRunParameters>
<Parameter name="tests:seed" value="0x1ffa1d067056b0e6" />
<Parameter name="tests:culture" value="sw-TZ" />
</TestRunParameters>
</RunSettings>
See the .runsettings documentation at:
https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file.
Attribute Configuration Example
[assembly: Lucene.Net.Util.RandomSeed("0x1ffa1d067056b0e6")]
[assembly: NUnit.Framework.SetCulture("sw-TZ")]
lucene.testSettings.config File Configuration Example
Add a file named lucene.testSettings.config to the executable directory or
any directory between the executable and the root of the drive with the following contents.
{
"tests": {
"seed": "0x1ffa1d067056b0e6",
"culture": "sw-TZ"
}
}
Environment Variable Configuration Example
Variable | Value |
---|
lucene:tests:seed | 0x1ffa1d067056b0e6 |
lucene:tests:culture | sw-TZ |
Inheritance
System.Object
LuceneTestCase
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Lucene.Net.TestFramework.dll
Syntax
[LuceneTestCase.TestFixture]
public abstract class LuceneTestCase
Fields
|
Improve this Doc
View Source
DEFAULT_LINE_DOCS_FILE
Declaration
public const string DEFAULT_LINE_DOCS_FILE = "europarl.lines.txt.gz"
Field Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
JENKINS_LARGE_LINE_DOCS_FILE
Declaration
public const string JENKINS_LARGE_LINE_DOCS_FILE = "enwiki.random.lines.txt"
Field Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
Suite failure marker (any error in the test or suite scope).
Declaration
public static readonly bool SuiteFailureMarker
Field Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
TEST_VERSION_CURRENT
Use this constant when creating Analyzers and any other version-dependent stuff.
NOTE: Change this when development starts for new Lucene version:
Declaration
public const LuceneVersion TEST_VERSION_CURRENT = LuceneVersion.LUCENE_48
Field Value
Type |
Description |
Lucene.Net.Util.LuceneVersion |
|
Properties
|
Improve this Doc
View Source
DefaultCodecSupportsDocsWithField
Returns true if the codec "supports" docsWithField
(other codecs return MatchAllBits, because you couldnt write missing values before)
Declaration
public static bool DefaultCodecSupportsDocsWithField { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
DefaultCodecSupportsDocValues
Declaration
public static bool DefaultCodecSupportsDocValues { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
DefaultCodecSupportsFieldUpdates
Returns true if the codec "supports" field updates.
Declaration
public static bool DefaultCodecSupportsFieldUpdates { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
DefaultCodecSupportsMissingDocValues
Returns true if the default codec supports single valued docvalues with missing values
Declaration
public static bool DefaultCodecSupportsMissingDocValues { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
DefaultCodecSupportsSortedSet
Returns true if the default codec supports SORTED_SET docvalues
Declaration
public static bool DefaultCodecSupportsSortedSet { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
DoesntSupportOffsets
Declaration
protected static ICollection<string> DoesntSupportOffsets { get; }
Property Value
Type |
Description |
System.Collections.Generic.ICollection<System.String> |
|
|
Improve this Doc
View Source
LeaveTemporary
Leave temporary files on disk, even on successful runs.
Declaration
public static bool LeaveTemporary { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
When true
, Codecs for old Lucene version will support writing
indexes in that format. Defaults to false
, can be disabled by
specific tests on demand.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public static bool OldFormatImpersonationIsActive { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Random
Access to the current System.Random instance. It is safe to use
this method from multiple threads, etc., but it should be called while within a runner's
scope (so no static initializers). The returned System.Random instance will be
different when this method is called inside a BeforeClass() hook (static
suite scope) and within NUnit.Framework.SetUpAttribute/ NUnit.Framework.TearDownAttribute hooks or test methods.
The returned instance must not be shared with other threads or cross a single scope's
boundary. For example, a System.Random acquired within a test method shouldn't be reused
for another test case.
There is an overhead connected with getting the System.Random for a particular context
and thread. It is better to cache the System.Random locally if tight loops with multiple
invocations are present or create a derivative local System.Random for millions of calls
like this:
Random random = new J2N.Randomizer(Random.NextInt64());
// tight loop with many invocations.
Declaration
public static Random Random { get; }
Property Value
Type |
Description |
System.Random |
|
|
Improve this Doc
View Source
RandomMultiplier
A random multiplier which you should use when writing random tests:
multiply it by the number of iterations to scale your tests (for nightly builds).
Declaration
public static int RandomMultiplier { get; }
Property Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
TestAwaitsFix
Declaration
public static bool TestAwaitsFix { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
TestCodec
Gets the codec to run tests with.
Declaration
public static string TestCodec { get; }
Property Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
TestDirectory
Gets the directory to run tests with
Declaration
public static string TestDirectory { get; }
Property Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
Gets the docValuesFormat to run tests with
Declaration
public static string TestDocValuesFormat { get; }
Property Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
TestLineDocsFile
Declaration
public static string TestLineDocsFile { get; }
Property Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
TestName
Return the name of the currently executing test case.
Declaration
public virtual string TestName { get; }
Property Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
TestNightly
Declaration
public static bool TestNightly { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
TestPostingsFormat
Gets the postingsFormat to run tests with.
Declaration
public static string TestPostingsFormat { get; }
Property Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
TestSlow
Declaration
public static bool TestSlow { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
TestType
Gets the current type being tested.
Declaration
public static Type TestType { get; }
Property Value
Type |
Description |
System.Type |
|
|
Improve this Doc
View Source
TestWeekly
Declaration
public static bool TestWeekly { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
UseInfoStream
Declaration
public static bool UseInfoStream { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Verbose
True if and only if tests are run in verbose mode. If this flag is false
tests are not expected to print any messages.
Declaration
public static bool Verbose { get; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
|
Improve this Doc
View Source
AfterClass()
Tears down random defaults and cleans up temporary files.
If you override this method, be sure to call base.AfterClass()
AFTER
tearing down your test fixture.
Declaration
[OneTimeTearDown]
public virtual void AfterClass()
|
Improve this Doc
View Source
AssertDeletedDocsEquals(String, IndexReader, IndexReader)
Declaration
public virtual void AssertDeletedDocsEquals(string info, IndexReader leftReader, IndexReader rightReader)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
Lucene.Net.Index.IndexReader |
rightReader |
|
|
Improve this Doc
View Source
AssertDocsAndPositionsEnumEquals(String, DocsAndPositionsEnum, DocsAndPositionsEnum)
Checks docs + freqs + positions + payloads, sequentially.
Declaration
public virtual void AssertDocsAndPositionsEnumEquals(string info, DocsAndPositionsEnum leftDocs, DocsAndPositionsEnum rightDocs)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.DocsAndPositionsEnum |
leftDocs |
|
Lucene.Net.Index.DocsAndPositionsEnum |
rightDocs |
|
|
Improve this Doc
View Source
AssertDocsEnumEquals(String, DocsEnum, DocsEnum, Boolean)
Checks docs + freqs, sequentially.
Declaration
public virtual void AssertDocsEnumEquals(string info, DocsEnum leftDocs, DocsEnum rightDocs, bool hasFreqs)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.DocsEnum |
leftDocs |
|
Lucene.Net.Index.DocsEnum |
rightDocs |
|
System.Boolean |
hasFreqs |
|
|
Improve this Doc
View Source
AssertDocsSkippingEquals(String, IndexReader, Int32, DocsEnum, DocsEnum, Boolean)
Declaration
public virtual void AssertDocsSkippingEquals(string info, IndexReader leftReader, int docFreq, DocsEnum leftDocs, DocsEnum rightDocs, bool hasFreqs)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
System.Int32 |
docFreq |
|
Lucene.Net.Index.DocsEnum |
leftDocs |
|
Lucene.Net.Index.DocsEnum |
rightDocs |
|
System.Boolean |
hasFreqs |
|
|
Improve this Doc
View Source
AssertDocValuesEquals(String, IndexReader, IndexReader)
Checks that docvalues across all fields are equivalent.
Declaration
public virtual void AssertDocValuesEquals(string info, IndexReader leftReader, IndexReader rightReader)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
Lucene.Net.Index.IndexReader |
rightReader |
|
|
Improve this Doc
View Source
AssertDocValuesEquals(String, Int32, NumericDocValues, NumericDocValues)
Declaration
public virtual void AssertDocValuesEquals(string info, int num, NumericDocValues leftDocValues, NumericDocValues rightDocValues)
Parameters
Type |
Name |
Description |
System.String |
info |
|
System.Int32 |
num |
|
Lucene.Net.Index.NumericDocValues |
leftDocValues |
|
Lucene.Net.Index.NumericDocValues |
rightDocValues |
|
|
Improve this Doc
View Source
AssertFieldInfosEquals(String, IndexReader, IndexReader)
Declaration
public virtual void AssertFieldInfosEquals(string info, IndexReader leftReader, IndexReader rightReader)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
Lucene.Net.Index.IndexReader |
rightReader |
|
|
Improve this Doc
View Source
AssertFieldsEquals(String, IndexReader, Fields, Fields, Boolean)
Declaration
public virtual void AssertFieldsEquals(string info, IndexReader leftReader, Fields leftFields, Fields rightFields, bool deep)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
Lucene.Net.Index.Fields |
leftFields |
|
Lucene.Net.Index.Fields |
rightFields |
|
System.Boolean |
deep |
|
|
Improve this Doc
View Source
AssertFieldStatisticsEquals(String, Fields, Fields)
Checks that top-level statistics on Lucene.Net.Index.Fields are the same.
Declaration
public virtual void AssertFieldStatisticsEquals(string info, Fields leftFields, Fields rightFields)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.Fields |
leftFields |
|
Lucene.Net.Index.Fields |
rightFields |
|
|
Improve this Doc
View Source
AssertNormsEquals(String, IndexReader, IndexReader)
Checks that norms are the same across all fields.
Declaration
public virtual void AssertNormsEquals(string info, IndexReader leftReader, IndexReader rightReader)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
Lucene.Net.Index.IndexReader |
rightReader |
|
|
Improve this Doc
View Source
AssertPositionsSkippingEquals(String, IndexReader, Int32, DocsAndPositionsEnum, DocsAndPositionsEnum)
Checks advancing docs + positions.
Declaration
public virtual void AssertPositionsSkippingEquals(string info, IndexReader leftReader, int docFreq, DocsAndPositionsEnum leftDocs, DocsAndPositionsEnum rightDocs)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
System.Int32 |
docFreq |
|
Lucene.Net.Index.DocsAndPositionsEnum |
leftDocs |
|
Lucene.Net.Index.DocsAndPositionsEnum |
rightDocs |
|
|
Improve this Doc
View Source
AssertReaderEquals(String, IndexReader, IndexReader)
Declaration
public virtual void AssertReaderEquals(string info, IndexReader leftReader, IndexReader rightReader)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
Lucene.Net.Index.IndexReader |
rightReader |
|
|
Improve this Doc
View Source
AssertReaderStatisticsEquals(String, IndexReader, IndexReader)
Checks that reader-level statistics are the same.
Declaration
public virtual void AssertReaderStatisticsEquals(string info, IndexReader leftReader, IndexReader rightReader)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
Lucene.Net.Index.IndexReader |
rightReader |
|
|
Improve this Doc
View Source
AssertSaneFieldCaches(String)
Asserts that Lucene.Net.Util.FieldCacheSanityChecker does not detect any
problems with Lucene.Net.Search.FieldCache.DEFAULT.
If any problems are found, they are logged to Lucene.Net.Util.SystemConsole.Error
(allong with the msg) when the Assertion is thrown.
This method is called by TearDown() after every test method,
however Lucene.Net.Index.IndexReaders scoped inside test methods may be garbage
collected prior to this method being called, causing errors to
be overlooked. Tests are encouraged to keep their Lucene.Net.Index.IndexReaders
scoped at the class level, or to explicitly call this method
directly in the same scope as the Lucene.Net.Index.IndexReader.
Declaration
protected static void AssertSaneFieldCaches(string msg)
Parameters
Type |
Name |
Description |
System.String |
msg |
|
See Also
Lucene.Net.Util.FieldCacheSanityChecker
|
Improve this Doc
View Source
AssertStoredFieldEquals(String, IIndexableField, IIndexableField)
Checks that two stored fields are equivalent.
Declaration
public virtual void AssertStoredFieldEquals(string info, IIndexableField leftField, IIndexableField rightField)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IIndexableField |
leftField |
|
Lucene.Net.Index.IIndexableField |
rightField |
|
|
Improve this Doc
View Source
AssertStoredFieldsEquals(String, IndexReader, IndexReader)
Checks that stored fields of all documents are the same.
Declaration
public virtual void AssertStoredFieldsEquals(string info, IndexReader leftReader, IndexReader rightReader)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
Lucene.Net.Index.IndexReader |
rightReader |
|
|
Improve this Doc
View Source
AssertTermsEnumEquals(String, IndexReader, TermsEnum, TermsEnum, Boolean)
Checks the terms enum sequentially.
If deep
is false, it does a 'shallow' test that doesnt go down to the docsenums.
Declaration
public virtual void AssertTermsEnumEquals(string info, IndexReader leftReader, TermsEnum leftTermsEnum, TermsEnum rightTermsEnum, bool deep)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
Lucene.Net.Index.TermsEnum |
leftTermsEnum |
|
Lucene.Net.Index.TermsEnum |
rightTermsEnum |
|
System.Boolean |
deep |
|
|
Improve this Doc
View Source
AssertTermsEquals(String, IndexReader, Terms, Terms, Boolean)
Lucene.Net.Index.Terms API equivalency.
Declaration
public virtual void AssertTermsEquals(string info, IndexReader leftReader, Terms leftTerms, Terms rightTerms, bool deep)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
Lucene.Net.Index.Terms |
leftTerms |
|
Lucene.Net.Index.Terms |
rightTerms |
|
System.Boolean |
deep |
|
|
Improve this Doc
View Source
AssertTermsStatisticsEquals(String, Terms, Terms)
Checks collection-level statistics on Lucene.Net.Index.Terms.
Declaration
public virtual void AssertTermsStatisticsEquals(string info, Terms leftTerms, Terms rightTerms)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.Terms |
leftTerms |
|
Lucene.Net.Index.Terms |
rightTerms |
|
|
Improve this Doc
View Source
AssertTermStatsEquals(String, TermsEnum, TermsEnum)
Checks term-level statistics.
Declaration
public virtual void AssertTermStatsEquals(string info, TermsEnum leftTermsEnum, TermsEnum rightTermsEnum)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.TermsEnum |
leftTermsEnum |
|
Lucene.Net.Index.TermsEnum |
rightTermsEnum |
|
|
Improve this Doc
View Source
AssertTermVectorsEquals(String, IndexReader, IndexReader)
Checks that term vectors across all fields are equivalent.
Declaration
public virtual void AssertTermVectorsEquals(string info, IndexReader leftReader, IndexReader rightReader)
Parameters
Type |
Name |
Description |
System.String |
info |
|
Lucene.Net.Index.IndexReader |
leftReader |
|
Lucene.Net.Index.IndexReader |
rightReader |
|
|
Improve this Doc
View Source
AsSet(Object[])
Return args
as a System.Collections.Generic.ISet<T> instance. The order of elements is not
preserved in enumerators.
Declaration
public static ISet<object> AsSet(params object[] args)
Parameters
Type |
Name |
Description |
System.Object[] |
args |
|
Returns
Type |
Description |
System.Collections.Generic.ISet<System.Object> |
|
|
Improve this Doc
View Source
AssumeFalse(String, Boolean)
Declaration
public static void AssumeFalse(string msg, bool condition)
Parameters
Type |
Name |
Description |
System.String |
msg |
Message to be included in the exception's string.
|
System.Boolean |
condition |
If true an NUnit.Framework.InconclusiveException is
thrown by this method and the test case (should be) ignored (or
rather technically, flagged as a failure not passing a certain
assumption). Tests that are assumption-failures do not break
builds (again: typically).
|
|
Improve this Doc
View Source
AssumeNoException(String, Exception)
Declaration
public static void AssumeNoException(string msg, Exception e)
Parameters
Type |
Name |
Description |
System.String |
msg |
|
System.Exception |
e |
|
|
Improve this Doc
View Source
AssumeTrue(String, Boolean)
Declaration
public static void AssumeTrue(string msg, bool condition)
Parameters
Type |
Name |
Description |
System.String |
msg |
Message to be included in the exception's string.
|
System.Boolean |
condition |
If false an NUnit.Framework.InconclusiveException is
thrown by this method and the test case (should be) ignored (or
rather technically, flagged as a failure not passing a certain
assumption). Tests that are assumption-failures do not break
builds (again: typically).
|
|
Improve this Doc
View Source
AtLeast(Int32)
Declaration
public static int AtLeast(int i)
Parameters
Type |
Name |
Description |
System.Int32 |
i |
|
Returns
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
AtLeast(Random, Int32)
Returns a number of at least i
The actual number returned will be influenced by whether TestNightly
is active and RandomMultiplier, but also with some random fudge.
Declaration
public static int AtLeast(Random random, int i)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
System.Int32 |
i |
|
Returns
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
BeforeClass()
Sets up dependency injection of codec factories for running the test class,
and also picks random defaults for culture, time zone, similarity, and default codec.
If you override this method, be sure to call base.BeforeClass()
BEFORE setting
up your test fixture.
Declaration
[OneTimeSetUp]
public virtual void BeforeClass()
|
Improve this Doc
View Source
CreateTempDir()
Creates an empty, temporary folder (when the name of the folder is of no importance).
Declaration
public static DirectoryInfo CreateTempDir()
Returns
Type |
Description |
System.IO.DirectoryInfo |
|
See Also
|
Improve this Doc
View Source
CreateTempDir(String)
Creates an empty, temporary folder with the given name prefix under the
system's System.IO.Path.GetTempPath.
The folder will be automatically removed after the
test class completes successfully. The test should close any file handles that would prevent
the folder from being removed.
Declaration
public static DirectoryInfo CreateTempDir(string prefix)
Parameters
Type |
Name |
Description |
System.String |
prefix |
|
Returns
Type |
Description |
System.IO.DirectoryInfo |
|
|
Improve this Doc
View Source
CreateTempFile()
Creates an empty temporary file.
Declaration
public static FileInfo CreateTempFile()
Returns
Type |
Description |
System.IO.FileInfo |
|
See Also
|
Improve this Doc
View Source
CreateTempFile(String, String)
Creates an empty file with the given prefix and suffix under the
system's System.IO.Path.GetTempPath.
The file will be automatically removed after the
test class completes successfully. The test should close any file handles that would prevent
the folder from being removed.
Declaration
public static FileInfo CreateTempFile(string prefix, string suffix)
Parameters
Type |
Name |
Description |
System.String |
prefix |
|
System.String |
suffix |
|
Returns
Type |
Description |
System.IO.FileInfo |
|
|
Improve this Doc
View Source
CultureForName(String)
return a System.Globalization.CultureInfo object equivalent to its programmatic name.
Declaration
public static CultureInfo CultureForName(string localeName)
Parameters
Type |
Name |
Description |
System.String |
localeName |
|
Returns
Type |
Description |
System.Globalization.CultureInfo |
|
|
Improve this Doc
View Source
DumpArray(String, Object[], TextWriter)
Declaration
public static void DumpArray(string label, object[] objs, TextWriter stream)
Parameters
Type |
Name |
Description |
System.String |
label |
|
System.Object[] |
objs |
|
System.IO.TextWriter |
stream |
|
See Also
|
Improve this Doc
View Source
DumpEnumerator(String, IEnumerator, TextWriter)
Convenience method for logging an enumerator.
Declaration
public static void DumpEnumerator(string label, IEnumerator iter, TextWriter stream)
Parameters
Type |
Name |
Description |
System.String |
label |
String logged before/after the items in the enumerator.
|
System.Collections.IEnumerator |
iter |
Each element is ToString()ed and logged on it's own line. If iter is null this is logged differnetly then an empty enumerator.
|
System.IO.TextWriter |
stream |
Stream to log messages to.
|
|
Improve this Doc
View Source
GetDataFile(String)
Gets a resource from the classpath as System.IO.Stream. This method should only
be used, if a real file is needed. To get a stream, code should prefer
J2N.AssemblyExtensions.FindAndGetManifestResourceStream(System.Reflection.Assembly,System.Type,System.String) using
this.GetType().Assembly
and this.GetType()
.
Declaration
protected virtual Stream GetDataFile(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
Type |
Description |
System.IO.Stream |
|
|
Improve this Doc
View Source
GetFullMethodName(String)
Declaration
protected string GetFullMethodName(string memberName = "")
Parameters
Type |
Name |
Description |
System.String |
memberName |
|
Returns
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
GetOnlySegmentReader(DirectoryReader)
Some tests expect the directory to contain a single segment, and want to
do tests on that segment's reader. This is an utility method to help them.
Declaration
public static SegmentReader GetOnlySegmentReader(DirectoryReader reader)
Parameters
Type |
Name |
Description |
Lucene.Net.Index.DirectoryReader |
reader |
|
Returns
Type |
Description |
Lucene.Net.Index.SegmentReader |
|
|
Improve this Doc
View Source
MaybeWrapReader(IndexReader)
Sometimes wrap the Lucene.Net.Index.IndexReader as slow, parallel or filter reader (or
combinations of that)
Declaration
public static IndexReader MaybeWrapReader(IndexReader r)
Parameters
Type |
Name |
Description |
Lucene.Net.Index.IndexReader |
r |
|
Returns
Type |
Description |
Lucene.Net.Index.IndexReader |
|
|
Improve this Doc
View Source
NewAlcoholicMergePolicy()
Declaration
public static AlcoholicMergePolicy NewAlcoholicMergePolicy()
Returns
|
Improve this Doc
View Source
NewAlcoholicMergePolicy(Random, TimeZoneInfo)
Declaration
public static AlcoholicMergePolicy NewAlcoholicMergePolicy(Random random, TimeZoneInfo timeZone)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
System.TimeZoneInfo |
timeZone |
|
Returns
|
Improve this Doc
View Source
NewDirectory()
Returns a new Lucene.Net.Store.Directory instance. Use this when the test does not
care about the specific Lucene.Net.Store.Directory implementation (most tests).
The Lucene.Net.Store.Directory is wrapped with BaseDirectoryWrapper.
This means usually it will be picky, such as ensuring that you
properly dispose it and close all open files in your test. It will emulate
some features of Windows, such as not allowing open files to be
overwritten.
Declaration
public static BaseDirectoryWrapper NewDirectory()
Returns
|
Improve this Doc
View Source
NewDirectory(Directory)
Returns a new Lucene.Net.Store.Directory instance, with contents copied from the
provided directory. See NewDirectory() for more
information.
Declaration
public static BaseDirectoryWrapper NewDirectory(Directory d)
Parameters
Type |
Name |
Description |
Lucene.Net.Store.Directory |
d |
|
Returns
|
Improve this Doc
View Source
NewDirectory(Random)
Returns a new Lucene.Net.Store.Directory instance, using the specified random
.
See NewDirectory() for more information.
Declaration
public static BaseDirectoryWrapper NewDirectory(Random random)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Returns
|
Improve this Doc
View Source
NewDirectory(Random, Directory)
Returns a new Lucene.Net.Store.Directory instance, using the specified random
with contents copied from the provided directory
. See
NewDirectory() for more information.
Declaration
public static BaseDirectoryWrapper NewDirectory(Random random, Directory directory)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Lucene.Net.Store.Directory |
directory |
|
Returns
|
Improve this Doc
View Source
NewField(Random, String, String, FieldType)
Declaration
public static Field NewField(Random random, string name, string value, FieldType type)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
System.String |
name |
|
System.String |
value |
|
Lucene.Net.Documents.FieldType |
type |
|
Returns
Type |
Description |
Lucene.Net.Documents.Field |
|
|
Improve this Doc
View Source
NewField(String, String, FieldType)
Declaration
public static Field NewField(string name, string value, FieldType type)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.String |
value |
|
Lucene.Net.Documents.FieldType |
type |
|
Returns
Type |
Description |
Lucene.Net.Documents.Field |
|
|
Improve this Doc
View Source
NewFSDirectory(DirectoryInfo)
Returns a new Lucene.Net.Store.FSDirectory instance over the given file, which must be a folder.
Declaration
public static BaseDirectoryWrapper NewFSDirectory(DirectoryInfo d)
Parameters
Type |
Name |
Description |
System.IO.DirectoryInfo |
d |
|
Returns
|
Improve this Doc
View Source
NewFSDirectory(DirectoryInfo, LockFactory)
Returns a new Lucene.Net.Store.FSDirectory instance over the given file, which must be a folder.
Declaration
public static BaseDirectoryWrapper NewFSDirectory(DirectoryInfo d, LockFactory lf)
Parameters
Type |
Name |
Description |
System.IO.DirectoryInfo |
d |
|
Lucene.Net.Store.LockFactory |
lf |
|
Returns
|
Improve this Doc
View Source
NewIndexWriterConfig(LuceneVersion, Analyzer)
Create a new Lucene.Net.Index.IndexWriterConfig with random defaults.
Declaration
public static IndexWriterConfig NewIndexWriterConfig(LuceneVersion v, Analyzer a)
Parameters
Type |
Name |
Description |
Lucene.Net.Util.LuceneVersion |
v |
|
Lucene.Net.Analysis.Analyzer |
a |
|
Returns
Type |
Description |
Lucene.Net.Index.IndexWriterConfig |
|
|
Improve this Doc
View Source
NewIndexWriterConfig(Random, LuceneVersion, Analyzer)
Create a new Lucene.Net.Index.IndexWriterConfig with random defaults using the specified random
.
Declaration
public static IndexWriterConfig NewIndexWriterConfig(Random random, LuceneVersion v, Analyzer a)
Parameters
Type |
Name |
Description |
System.Random |
random |
A random instance (usually Random).
|
Lucene.Net.Util.LuceneVersion |
v |
|
Lucene.Net.Analysis.Analyzer |
a |
|
Returns
Type |
Description |
Lucene.Net.Index.IndexWriterConfig |
|
|
Improve this Doc
View Source
NewIOContext(Random)
Declaration
public static IOContext NewIOContext(Random random)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Returns
Type |
Description |
Lucene.Net.Store.IOContext |
|
|
Improve this Doc
View Source
NewIOContext(Random, IOContext)
Declaration
public static IOContext NewIOContext(Random random, IOContext oldContext)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Lucene.Net.Store.IOContext |
oldContext |
|
Returns
Type |
Description |
Lucene.Net.Store.IOContext |
|
|
Improve this Doc
View Source
NewLogMergePolicy()
Declaration
public static LogMergePolicy NewLogMergePolicy()
Returns
Type |
Description |
Lucene.Net.Index.LogMergePolicy |
|
|
Improve this Doc
View Source
NewLogMergePolicy(Boolean)
Declaration
public static MergePolicy NewLogMergePolicy(bool useCFS)
Parameters
Type |
Name |
Description |
System.Boolean |
useCFS |
|
Returns
Type |
Description |
Lucene.Net.Index.MergePolicy |
|
|
Improve this Doc
View Source
NewLogMergePolicy(Boolean, Int32)
Declaration
public static MergePolicy NewLogMergePolicy(bool useCFS, int mergeFactor)
Parameters
Type |
Name |
Description |
System.Boolean |
useCFS |
|
System.Int32 |
mergeFactor |
|
Returns
Type |
Description |
Lucene.Net.Index.MergePolicy |
|
|
Improve this Doc
View Source
NewLogMergePolicy(Int32)
Declaration
public static MergePolicy NewLogMergePolicy(int mergeFactor)
Parameters
Type |
Name |
Description |
System.Int32 |
mergeFactor |
|
Returns
Type |
Description |
Lucene.Net.Index.MergePolicy |
|
|
Improve this Doc
View Source
NewLogMergePolicy(Random)
Declaration
public static LogMergePolicy NewLogMergePolicy(Random random)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Returns
Type |
Description |
Lucene.Net.Index.LogMergePolicy |
|
|
Improve this Doc
View Source
NewMergePolicy()
Declaration
public static MergePolicy NewMergePolicy()
Returns
Type |
Description |
Lucene.Net.Index.MergePolicy |
|
|
Improve this Doc
View Source
NewMergePolicy(Random)
Declaration
public static MergePolicy NewMergePolicy(Random r)
Parameters
Type |
Name |
Description |
System.Random |
r |
|
Returns
Type |
Description |
Lucene.Net.Index.MergePolicy |
|
|
Improve this Doc
View Source
NewMockDirectory()
Declaration
public static MockDirectoryWrapper NewMockDirectory()
Returns
|
Improve this Doc
View Source
NewMockDirectory(Random)
Declaration
public static MockDirectoryWrapper NewMockDirectory(Random random)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Returns
|
Improve this Doc
View Source
NewMockFSDirectory(DirectoryInfo)
Declaration
public static MockDirectoryWrapper NewMockFSDirectory(DirectoryInfo d)
Parameters
Type |
Name |
Description |
System.IO.DirectoryInfo |
d |
|
Returns
|
Improve this Doc
View Source
NewSearcher(IndexReader)
Create a new searcher over the reader. this searcher might randomly use
threads.
Declaration
public static IndexSearcher NewSearcher(IndexReader r)
Parameters
Type |
Name |
Description |
Lucene.Net.Index.IndexReader |
r |
|
Returns
Type |
Description |
Lucene.Net.Search.IndexSearcher |
|
|
Improve this Doc
View Source
NewSearcher(IndexReader, Boolean)
Create a new searcher over the reader. This searcher might randomly use
threads.
Declaration
public static IndexSearcher NewSearcher(IndexReader r, bool maybeWrap)
Parameters
Type |
Name |
Description |
Lucene.Net.Index.IndexReader |
r |
|
System.Boolean |
maybeWrap |
|
Returns
Type |
Description |
Lucene.Net.Search.IndexSearcher |
|
|
Improve this Doc
View Source
NewSearcher(IndexReader, Boolean, Boolean)
Create a new searcher over the reader. This searcher might randomly use
threads. If maybeWrap
is true, this searcher might wrap the
reader with one that returns null for Lucene.Net.Index.CompositeReader.GetSequentialSubReaders(). If
wrapWithAssertions
is true, this searcher might be an
AssertingIndexSearcher instance.
Declaration
public static IndexSearcher NewSearcher(IndexReader r, bool maybeWrap, bool wrapWithAssertions)
Parameters
Type |
Name |
Description |
Lucene.Net.Index.IndexReader |
r |
|
System.Boolean |
maybeWrap |
|
System.Boolean |
wrapWithAssertions |
|
Returns
Type |
Description |
Lucene.Net.Search.IndexSearcher |
|
|
Improve this Doc
View Source
NewStringField(Random, String, String, Field.Store)
Declaration
public static Field NewStringField(Random random, string name, string value, Field.Store stored)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
System.String |
name |
|
System.String |
value |
|
Lucene.Net.Documents.Field.Store |
stored |
|
Returns
Type |
Description |
Lucene.Net.Documents.Field |
|
|
Improve this Doc
View Source
NewStringField(String, String, Field.Store)
Declaration
public static Field NewStringField(string name, string value, Field.Store stored)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.String |
value |
|
Lucene.Net.Documents.Field.Store |
stored |
|
Returns
Type |
Description |
Lucene.Net.Documents.Field |
|
|
Improve this Doc
View Source
NewTextField(Random, String, String, Field.Store)
Declaration
public static Field NewTextField(Random random, string name, string value, Field.Store stored)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
System.String |
name |
|
System.String |
value |
|
Lucene.Net.Documents.Field.Store |
stored |
|
Returns
Type |
Description |
Lucene.Net.Documents.Field |
|
|
Improve this Doc
View Source
NewTextField(String, String, Field.Store)
Declaration
public static Field NewTextField(string name, string value, Field.Store stored)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.String |
value |
|
Lucene.Net.Documents.Field.Store |
stored |
|
Returns
Type |
Description |
Lucene.Net.Documents.Field |
|
|
Improve this Doc
View Source
NewTieredMergePolicy()
Declaration
public static TieredMergePolicy NewTieredMergePolicy()
Returns
Type |
Description |
Lucene.Net.Index.TieredMergePolicy |
|
|
Improve this Doc
View Source
NewTieredMergePolicy(Random)
Declaration
public static TieredMergePolicy NewTieredMergePolicy(Random random)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Returns
Type |
Description |
Lucene.Net.Index.TieredMergePolicy |
|
|
Improve this Doc
View Source
RandomCulture(Random)
Declaration
public static CultureInfo RandomCulture(Random random)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Returns
Type |
Description |
System.Globalization.CultureInfo |
|
|
Improve this Doc
View Source
RandomGaussian()
Returns the next pseudorandom, Gaussian ("normally") distributed
double
value with mean 0.0
and standard
deviation 1.0
from this random number generator's sequence.
The general contract of RandomGaussian() is that one
System.Double value, chosen from (approximately) the usual
normal distribution with mean 0.0
and standard deviation
1.0
, is pseudorandomly generated and returned.
This uses the polar method of G. E. P. Box, M. E. Muller, and
G. Marsaglia, as described by Donald E. Knuth in The Art of
Computer Programming, Volume 3: Seminumerical Algorithms,
section 3.4.1, subsection C, algorithm P. Note that it generates two
independent values at the cost of only one call to System.Math.Log(System.Double)
and one call to System.Math.Sqrt(System.Double).
Declaration
public double RandomGaussian()
Returns
Type |
Description |
System.Double |
The next pseudorandom, Gaussian ("normally") distributed
System.Double value with mean 0.0 and
standard deviation 1.0 from this random number
generator's sequence.
|
|
Improve this Doc
View Source
RandomTimeZone(Random)
Declaration
public static TimeZoneInfo RandomTimeZone(Random random)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Returns
Type |
Description |
System.TimeZoneInfo |
|
|
Improve this Doc
View Source
Rarely()
Declaration
public static bool Rarely()
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Rarely(Random)
Returns true if something should happen rarely,
The actual number returned will be influenced by whether TestNightly
is active and RandomMultiplier.
Declaration
public static bool Rarely(Random random)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
SetUp()
For subclasses to override. Overrides must call base.SetUp()
.
Declaration
[SetUp]
public virtual void SetUp()
|
Improve this Doc
View Source
SlowFileExists(Directory, String)
Returns true if the file exists (can be opened), false
if it cannot be opened, and (unlike .NET's
System.IO.File.Exists(System.String)) if there's some
unexpected error, returns false
.
Declaration
public static bool SlowFileExists(Directory dir, string fileName)
Parameters
Type |
Name |
Description |
Lucene.Net.Store.Directory |
dir |
|
System.String |
fileName |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
TearDown()
For subclasses to override. Overrides must call base.TearDown()
.
Declaration
[TearDown]
public virtual void TearDown()
|
Improve this Doc
View Source
Usually()
Declaration
public static bool Usually()
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Usually(Random)
Declaration
public static bool Usually(Random random)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Returns
Type |
Description |
System.Boolean |
|