Class NatsStreamingFixture
Used to run a Docker nats-streaming container on the current machine as a test fixture while tests are being performed and then deletes the container when the fixture is disposed.
Implements
Inherited Members
Namespace: Neon.Xunit
Assembly: Neon.Xunit.dll
Syntax
public sealed class NatsStreamingFixture : ContainerFixture, ITestFixture
Remarks
This fixture assumes that NATS-SERVER is not currently running on the local workstation or as a container named nats-test. You may see port conflict errors if either of these conditions are not true.
A somewhat safer but slower alternative, is to use the DockerFixture instead and add NatsStreamingFixture as a subfixture. The advantage is that DockerFixture will ensure that all (potentially conflicting) containers are removed before the NatsFixture fixture is started.
Use Restart() to clear the NATS-SATREAMIN server state by restarting its Docker container. This also returns the new client connection.
Constructors
NatsStreamingFixture()
Constructs the fixture.
Declaration
public NatsStreamingFixture()
Properties
Connection
Returns the NATS-STREAMING connection.
Declaration
public IStanConnection Connection { get; }
Property Value
Type | Description |
---|---|
IStanConnection |
Methods
Reset()
This method completely resets the fixture by removing and recreating the NATS-STREAMING container.
Declaration
public override void Reset()
Overrides
Restart()
Restarts the NATS container to clear any previous state and returns the new client connection.
Declaration
public IStanConnection Restart()
Returns
Type | Description |
---|---|
IStanConnection | The new connection. |
Start(string, string, string[])
Starts a NATS-STREAMING container if it's not already running. You'll generally want to call this in your test class constructor instead of Start(Action).
note
You'll need to call StartAsComposed(string, string, string[]) instead when this fixture is being added to a ComposedFixture.
Declaration
public TestFixtureStatus Start(string image = null, string name = "nats-streaming-test", string[] args = null)
Parameters
Type | Name | Description |
---|---|---|
string | image | Optionally specifies the NATS-STREAMING container image. This defaults to ghcr.io/neonrelease/nats-streaming:latest or ghcr.io/neonrelease-dev/nats-streaming:latest depending on whether the assembly was built from a git release branch or not. |
string | name | Optionally specifies the NATS-STREAMING container name (defaults to |
string[] | args | Optional NATS-STREAMING server command line arguments. |
Returns
Type | Description |
---|---|
TestFixtureStatus | Started if the fixture wasn't previously started and this method call started it or AlreadyRunning if the fixture was already running. |
StartAsComposed(string, string, string[])
Used to start the fixture within a ComposedFixture.
Declaration
public void StartAsComposed(string image = null, string name = "nats-streaming-test", string[] args = null)
Parameters
Type | Name | Description |
---|---|---|
string | image | Optionally specifies the NATS container image. This defaults to ghcr.io/neonrelease/nats-streaming:latest or ghcr.io/neonrelease-dev/nats-streaming:latest depending on whether the assembly was built from a git release branch or not. |
string | name | Optionally specifies the container name (defaults to |
string[] | args | Optional NATS-STREAMING server command line arguments. note
Reasonable defaults are used when |