Class CodeFixture
Used to execute some custom code while ComposedFixture is starting subfixtures. This is typically used to perform additional configuration of a ServiceMap, etc. to configure components like NeonService instances for integration testing.
Implements
Inherited Members
Namespace: Neon.Xunit
Assembly: Neon.Xunit.dll
Syntax
public class CodeFixture : TestFixture, ITestFixture
Remarks
A common use case for this is to deploy a cluster of services in-process with databases and/or workflow engines deployed as local Docker containers by other test fixtures. The idea is to add a CodeFixture via AddFixture<TFixture>(string, TFixture, Action<TFixture>, int), passing the Action as a function that performs any custom configuration.
note
CodeFixture really doesn't do anything by itself. It's purpose is simply to provide a mechanism for adding and executing your custom code to ComposedFixture.
You action code can then do things like initialize the database schema and test data as well as initializing a ServiceMap by setting the environment variables and configuration files for any NeonService instances that will also be deployed for the test. Many integration test scenarios follow this pattern:
-
Implement a unit test derived from
IClassFixture<ComposedFixture>
. - In the test constructor, add any database and/or workflow engine fixtures as group=0. These fixtures will start in parallel and will be running before any fixtures in subsequent groups are started.
- Then add a CodeFixture to the cluster fixture via AddFixture<TFixture>(string, TFixture, Action<TFixture>, int), passing your action as group=1.
- Your action should perform any custom configuration.
- Add your NeonService and/or other fixtures as group=2 or beyond, as required.
So when the ComposedFixture starts, it'll start the database/workflow engine fixtures first as group=0 and then start your CodeFixture as group=1 and your custom action can initialize the database and perhaps configure a ServiceMap. Once your action has returned, ComposedFixture will start the fixtures in any remaining groups with a configured database and ServiceMap before the test framework starts executing your tests cases.
Constructors
CodeFixture()
Constructs the fixture.
Declaration
public CodeFixture()
Methods
Dispose(bool)
Releases all associated resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | Pass |
Overrides
~CodeFixture()
Finalizer.
Declaration
protected ~CodeFixture()
Reset()
INTERNAL USE ONLY: Resets the fixture state.
Declaration
public override void Reset()