Click or drag to resize

CadenceFixture Class

Used to run the Docker nkubeio/cadence-dev container on the current machine as a test fixture while tests are being performed and then deletes the container when the fixture is disposed.
Inheritance Hierarchy

Namespace:  Neon.Xunit.Cadence
Assembly:  Neon.Xunit.Cadence (in Neon.Xunit.Cadence.dll) Version: 2.2.0
Syntax
public sealed class CadenceFixture : ContainerFixture

The CadenceFixture type exposes the following members.

Constructors
  NameDescription
Public methodCadenceFixture
Constructs the fixture.
Top
Properties
  NameDescription
Public propertyClient
Returns the CadenceClient to be used to interact with Cadence.
Public propertyContainerId
Returns the running container's short ID or null if the container has not been started.
(Inherited from ContainerFixture.)
Public propertyContainerName
Returns the running container's name or null if the container has not been started.
(Inherited from ContainerFixture.)
Public propertyHttpClient
Returns a HttpClient suitable for submitting requests to the HttpClient instance web server.
Public propertyIsRunning
Returns true if the fixture has been initialized.
(Inherited from TestFixture.)
Public propertyProxyClient

Returns a HttpClient suitable for submitting requests to the associated cadence-proxy process.

Note Note
This will return null if the cadence-proxy process was disabled by the settings.
Public propertySettings
Returns the settings used to connect to the Cadence cluster.
Public propertyState
Used by unit test classes to persist arbitrary name/value information across individual unit tests.
(Inherited from TestFixture.)
Top
Methods
  NameDescription
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from TestFixture.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodOnRestart
Called when an already started fixture is being restarted. This establishes a fresh Cadence connection.
(Overrides TestFixtureOnRestart.)
Public methodReset
This method completely resets the fixture by removing the Cadence container from Docker. Use Restart if you just want to restart a fresh Cadence instance.
(Overrides ContainerFixtureReset.)
Public methodRestart
Closes the existing Cadence connection and restarts the Cadence server and then establishes a new connection.
Public methodStart(Action)
Starts the fixture if it hasn't already been started including invoking the optional Action when the first time Start(Action) is called for a fixture instance.
(Inherited from TestFixture.)
Public methodStart(String, String, String, IEnumerableString, IEnumerableString, Boolean, Boolean, ContainerLimits) (Inherited from ContainerFixture.)
Public methodStart(CadenceSettings, String, String, String, String, LogLevel, Boolean, Boolean, String, Boolean, Boolean, ContainerLimits)

Starts a Cadence container if it's not already running. You'll generally want to call this in your test class constructor instead of Start(Action).

Public methodStartAsComposed(String, String, String, IEnumerableString, IEnumerableString, Boolean, Boolean, ContainerLimits)
Used to start the fixture within a ComposedFixture.
(Inherited from ContainerFixture.)
Public methodStartAsComposed(CadenceSettings, String, String, String, String, LogLevel, Boolean, Boolean, String, Boolean, Boolean, ContainerLimits)
Used to start the fixture within a ComposedFixture.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Fields
  NameDescription
Public fieldStatic memberDefaultDomain
The default domain configured for CadenceFixture clients.
Top
Remarks
Note Note

IMPORTANT: The base Neon TestFixture implementation DOES NOT support parallel test execution because fixtures may impact global machine state like starting a Docker container, modifying the local DNS hosts file, or configuring a test database.

You should explicitly disable parallel execution in all test assemblies that rely on test fixtures by adding a C# file called AssemblyInfo.cs with:

C#
[assembly: CollectionBehavior(DisableTestParallelization = true, MaxParallelThreads = 1)]

This fixture assumes that Cadence is not currently running on the local workstation or as a container named cadence-dev. You may see port conflict errors if either of these conditions are not true.

See Start(CadenceSettings, String, String, String, String, LogLevel, Boolean, Boolean, String, Boolean, Boolean, ContainerLimits) for more information about how this works.

Note Note
You can persist CadenceClient instances to the underlying State dictionary to make these clients available across all test methods. CadenceFixture ensures that any of these clients will be disposed when the fixture is disposed, reset, or restarted.
Thread Safety
Instance members of this type are safe for multi-threaded operations.
See Also