• API

    Show / Hide Table of Contents

    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
    System.Object
    LuceneTestFrameworkInitializer
    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()
    Namespace: Lucene.Net.Util
    Assembly: Lucene.Net.TestFramework.dll
    Syntax
    [SetUpFixture]
    public abstract class LuceneTestFrameworkInitializer

    Properties

    | Improve this Doc View Source

    CodecFactory

    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
    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    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 Source

    OneTimeSetUpBeforeTests()

    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()
    | Improve this Doc View Source

    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()
    | Improve this Doc View Source

    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()
    | Improve this Doc View Source

    TestFrameworkTearDown()

    Overridden in a derived class, can be used to tear down classes one-time for the test framework.

    Declaration
    protected virtual void TestFrameworkTearDown()
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)