Class LuceneTestFrameworkInitializer
LuceneTestFrameworkInitializer may be subclassed by end users in order to use standard dependency injection techniques for classes under test. A subclass of LuceneTestFrameworkInitializer will be executed automatically by NUnit. To work properly with the Lucene.NET test framework, the subclass must be placed outside of all namespaces, which ensures it is only executed 1 time per test assembly.
The following abstract factories can be overridden for testing purposes:
AbstractionFactory Method NameDefault | |
---|---|
Lucene.Net.Codecs.ICodecFactoryCodecFactoryTestCodecFactory | |
Lucene.Net.Codecs.IDocValuesFormatFactoryDocValuesFormatFactoryTestDocValuesFormatFactory | |
Lucene.Net.Codecs.IPostingsFormatFactoryPostingsFormatFactoryTestPostingsFormatFactory | |
Lucene.Net.Configuration.IConfigurationFactoryConfigurationFactoryLucene.Net.Configuration.TestConfigurationFactory |
Example:
// IMPORTANT: Do not put the initializer in a namespace
public class MyTestFrameworkInitializer : LuceneTestFrameworkInitializer
{
protected override IConfigurationFactory LoadConfigurationFactory()
{
// Inject a custom configuration factory
return new MyConfigurationFactory();
}
protected override void TestFrameworkSetUp()
{
// Inject a custom configuration factory
ConfigurationFactory = new MyConfigurationFactory();
// Do any additional dependency injection setup here
}
}
Inheritance
Inherited Members
Namespace: Lucene.Net.Util
Assembly: Lucene.Net.TestFramework.dll
Syntax
[SetUpFixture]
public abstract class LuceneTestFrameworkInitializer
Properties
| Improve this Doc View SourceCodecFactory
The Lucene.Net.Codecs.ICodecFactory implementation to use to load codecs during testing.
Declaration
protected static ICodecFactory CodecFactory { get; set; }
Property Value
Type | Description |
---|---|
Lucene.Net.Codecs.ICodecFactory |
ConfigurationFactory
The Lucene.Net.Configuration.IConfigurationFactory implementation to use to load configuration settings during testing. See: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/.
Declaration
[CLSCompliant(false)]
protected static IConfigurationFactory ConfigurationFactory { get; set; }
Property Value
Type | Description |
---|---|
Lucene.Net.Configuration.IConfigurationFactory |
DocValuesFormatFactory
The Lucene.Net.Codecs.IDocValuesFormatFactory implementation to use to load doc values during testing.
Declaration
protected static IDocValuesFormatFactory DocValuesFormatFactory { get; set; }
Property Value
Type | Description |
---|---|
Lucene.Net.Codecs.IDocValuesFormatFactory |
PostingsFormatFactory
The Lucene.Net.Codecs.IPostingsFormatFactory implementation to use to load postings formats during testing.
Declaration
protected static IPostingsFormatFactory PostingsFormatFactory { get; set; }
Property Value
Type | Description |
---|---|
Lucene.Net.Codecs.IPostingsFormatFactory |
Methods
| Improve this Doc View SourceOneTimeSetUpBeforeTests()
When this class is derived in a test assembly, this method is automatically called by NUnit one time before all tests run.
Declaration
[OneTimeSetUp]
protected void OneTimeSetUpBeforeTests()
OneTimeTearDownAfterTests()
When this class is derived in a test assembly, this method is automatically called by NUnit one time after all tests run.
Declaration
[OneTimeTearDown]
protected void OneTimeTearDownAfterTests()
TestFrameworkSetUp()
Overridden in a derived class, can be used to initialize factory instances that are injected into Lucene.NET during test operations, or perform other one-time initialization of the test framework setup.
NOTE: To initialize 1 time for your entire test library, only create a single derived class and place it outside of any namespace.
Declaration
protected virtual void TestFrameworkSetUp()
TestFrameworkTearDown()
Overridden in a derived class, can be used to tear down classes one-time for the test framework.
Declaration
protected virtual void TestFrameworkTearDown()