• NeonSDK
  • NeonKUBE
Search Results for

    Show / Hide Table of Contents
    • Neon
      • Build
    • Neon.Blazor
      • BlazorHelper
      • BodyOutlet
      • ClientRenderContext
      • DOMRectReadOnly
      • EventHandlers
      • FileDownloader
      • HtmlElement
      • IRenderContext
      • IntersectionChangedEventArgs
      • IntersectionObserver
      • IntersectionObserverContext
      • MobileDetector
      • NeonBlazorExtensions
      • ServerRenderContext
      • SwipeDirection
      • SwipeHandler
    • Neon.Blazor.Analyzers
      • SvgGenerator
      • SvgGenerator.Svg
    • Neon.BuildInfo
      • ThisAssembly
      • ThisAssembly.Git
      • ThisAssembly.Git.BaseVersion
      • ThisAssembly.Git.SemVer
    • Neon.CSharp
      • CSharpHelper
      • CompilerErrorException
      • MetadataReferences
    • Neon.Cassandra
      • KeyspaceStatus
      • RowSetExtensions
      • SchemaManager
      • SchemaManagerException
      • SchemaStatus
      • SessionExtensions
    • Neon.Collections
      • ArgDictionary
      • Bits
      • IObjectDictionary
      • NiceDictionary<TKey, TValue>
      • ObjectDictionary
    • Neon.Common
      • AppDomainExtensions
      • Block
      • BlockArray
      • ByteEncoding
      • ByteUnits
      • CommandLine
      • CommandLine.OptionDefinition
      • CommandLine.Redactor
      • CpuArchitecture
      • Credentials
      • DateTimeExtensions
      • EnumExtensions
      • EnvironmentParser
      • EnvironmentParser.Parser<T>
      • EnvironmentParser.Validator<T>
      • EnvironmentParser.VariableSource
      • ExceptionExtensions
      • ExecuteException
      • ExecuteResponse
      • GlobPattern
      • HexDumpOption
      • HttpClientExtensions
      • HttpResponseMessageExtensions
      • IEnumerableExtensions
      • ILabeled
      • IOExtensions
      • IServiceContainer
      • IStaticDirectoryExtensions
      • LabelSelector
      • LabelSelectorOptions
      • LabelSelector<TItem>
      • NeonAssemblyExtensions
      • NeonExtendedHelper
      • NeonHelper
      • NetFramework
      • NewtonsoftExtensions
      • NotReadyException
      • ProcessExtensions
      • ProgramEntrypoint
      • ProgramEntrypointAsync
      • ProgramExitException
      • ProgramRunner
      • RandomExtensions
      • ReflectionExtensions
      • SemanticVersion
      • ServiceContainer
      • StaticZipOptions
      • StringBuilderExtensions
      • StringExtensions
      • Stub
      • Stub.Value
      • TaskExtensions
      • TimeSpanExtensions
      • ToolException
      • TriState
      • WeakEventController
      • WindowsEdition
      • WindowsFeatureStatus
      • YamlDotNetExtensions
    • Neon.Cryptography
      • AesCipher
      • CryptoExtensions
      • CryptoHelper
      • NeonVault
      • Wildcard
    • Neon.Csv
      • CsvReader
      • CsvTableReader
      • CsvTableWriter
      • CsvWriter
    • Neon.Data
      • DateTimeJsonConverter
      • DateTimeOffsetJsonConverter
      • IEnhancedJsonConverter
      • IGeneratedServiceClient
      • IPersistableType
      • IPersistableType<T>
      • IRoundtripData
      • IntegerEnumConverter<TEnum>
      • NotifyPropertyChanged
      • RoundtripDataFactory
      • RoundtripDataHelper
      • TimeSpanJsonConverter
      • VersionJsonConverter
    • Neon.Deployment
      • AwsCli
      • DeploymentException
      • DeploymentHelper
      • DownloadManifest
      • DownloadPart
      • DownloadProgressDelegate
      • DownloadProgressType
      • GitHub
      • GitHubActionsApi
      • GitHubPackage
      • GitHubPackageApi
      • GitHubPackageType
      • GitHubPackageVersion
      • GitHubPackageVisibility
      • GitHubReleaseApi
      • GitHubRepoPath
      • GitHubTagApi
      • IProfileClient
      • IProfileRequest
      • IProfileResponse
      • MaintainerProfile
      • NotifyClient
      • OnePassword
      • OnePasswordException
      • ProfileException
      • ProfileHandlerResult
      • ProfileRequest
      • ProfileResponse
      • ProfileServer
      • ProfileStatus
      • XenServer
    • Neon.Deployment.CodeSigning
      • AzureProfile
      • CodeSigner
      • UsbTokenProfile
    • Neon.Diagnostics
      • AssertException
      • ConfigExtensions
      • ConsoleJsonLogExporter
      • ConsoleJsonLogExporterOptions
      • ConsoleTextLogExporter
      • ConsoleTextLogExporterOptions
      • ExceptionInfo
      • FileLogExporter
      • FileLogExporterFormat
      • FileLogExporterOptions
      • LogAsTraceProcessor
      • LogAsTraceProcessorOptions
      • LogAttributeNames
      • LogAttributes
      • LogEvent
      • LogEventInterceptor
      • LoggerExtensions
      • NullLogger
      • TelemetryHub
      • TelemetrySpanEventNames
      • TelemetrySpanExtensions
    • Neon.Docker
      • DockerClient
      • DockerNetwork
      • DockerNetworkContainer
      • DockerNetworkIpam
      • DockerNode
      • DockerNodeManagerStatus
      • DockerResponse
      • DockerSettings
      • DockerVolume
      • NetworkCreateResponse
      • ServiceBindOptions
      • ServiceConfig
      • ServiceContainerSpec
      • ServiceCredentialSpec
      • ServiceDetails
      • ServiceDiscreteResourceSpec
      • ServiceDnsConfig
      • ServiceEndpoint
      • ServiceEndpointMode
      • ServiceEndpointPortConfig
      • ServiceEndpointSpec
      • ServiceFile
      • ServiceGenericResources
      • ServiceGlobalSchedulingMode
      • ServiceHealthCheck
      • ServiceIsolationMode
      • ServiceListResponse
      • ServiceLogDriver
      • ServiceMode
      • ServiceMount
      • ServiceMountBindPropagation
      • ServiceMountConsistency
      • ServiceMountType
      • ServiceNamedResourceSpec
      • ServiceNetwork
      • ServicePlacement
      • ServicePlacementPreferences
      • ServicePlacementSpreadSettings
      • ServicePlatform
      • ServicePortMode
      • ServicePortProtocol
      • ServicePrivileges
      • ServiceReplicatedSchedulingMode
      • ServiceResourceSettings
      • ServiceResources
      • ServiceRestartCondition
      • ServiceRestartPolicy
      • ServiceRollbackConfig
      • ServiceRollbackFailureAction
      • ServiceRollbackOrder
      • ServiceSELinuxContext
      • ServiceSchedulingMode
      • ServiceSecret
      • ServiceSpec
      • ServiceTaskTemplate
      • ServiceTmpfsOptions
      • ServiceUpdateConfig
      • ServiceUpdateFailureAction
      • ServiceUpdateOrder
      • ServiceUpdateState
      • ServiceUpdateStatus
      • ServiceVersion
      • ServiceVirtualIP
      • ServiceVolumeDriverConfig
      • ServiceVolumeOptions
      • VolumeListResponse
    • Neon.GitHub
      • GitExtensions
      • GitHubCredentials
      • GitHubRepo
      • LocalRepoApi
      • NoLocalRepositoryException
      • RemoteRepoApi
      • RemoteRepoBranchApi
      • RemoteRepoIssueApi
      • RemoteRepoIssueCommentApi
      • RemoteRepoPath
      • RemoteRepoReleaseApi
      • RemoteRepoTagApi
    • Neon.HyperV
      • HyperVClient
      • HyperVDriverType
      • HyperVException
      • NetAdapter
      • VirtualDrive
      • VirtualIPAddress
      • VirtualMachine
      • VirtualMachineNetworkAdapter
      • VirtualMachineState
      • VirtualNat
      • VirtualSwitch
      • VirtualSwitchType
    • Neon.IO
      • BlockStream
      • FixedLengthStream
      • IStaticDirectory
      • IStaticFile
      • LineEnding
      • LinuxPath
      • LinuxPermissions
      • PreprocessReader
      • RelayStream
      • StaticDirectoryBase
      • StaticFileBase
      • SubStream
      • TempFile
      • TempFolder
    • Neon.JsonConverters
      • JsonDateTimeConverter
      • JsonGenericConverter<T>
      • JsonNullableDateTimeConverter
    • Neon.ModelGen
      • ActionResult<T>
      • ApiVersion
      • ApiVersionAttribute
      • BodyStreamAttribute
      • ControllerValidationAttribute
      • DataModelAttribute
      • EnumMember
      • FromBodyAttribute
      • FromHeaderAttribute
      • FromQueryAttribute
      • FromRouteAttribute
      • GeneratedClientAttribute
      • GeneratedMethodAttribute
      • GeneratedParamAttribute
      • HashSourceAttribute
      • HttpAttribute
      • HttpDeleteAttribute
      • HttpGetAttribute
      • HttpHeadAttribute
      • HttpOptionsAttribute
      • HttpPatchAttribute
      • HttpPostAttribute
      • HttpPutAttribute
      • IActionResult
      • ModelGenerator
      • ModelGeneratorOutput
      • ModelGeneratorSettings
      • NoCodeGenAttribute
      • NoControllerValidationAttribute
      • PassAs
      • PersistableAttribute
      • PersistableKeyAttribute
      • RouteAttribute
      • ServiceModelAttribute
      • TargetAttribute
      • UxFrameworks
    • Neon.Net
      • HttpApiException
      • HttpException
      • JsonClient
      • JsonClientPayload
      • JsonResponse
      • Jwt
      • LocalHostSection
      • NetConst
      • NetHelper
      • NetworkCidr
      • NetworkConfiguration
      • NetworkException
      • NetworkPorts
      • Pinger
      • ReachableHost
      • ReachableHostMode
      • StreamDocument
    • Neon.Postgres
      • ConnectionExtensions
      • DatabaseStatus
      • PreparedCommand
      • ReaderAsyncEnumerator
      • ReaderEnumerator
      • ReaderExtensions
      • SchemaManager
      • SchemaManagerException
      • SchemaStatus
    • Neon.Retry
      • ExponentialRetryPolicy
      • IRetryPolicy
      • LinearRetryPolicy
      • NoRetryPolicy
      • RetryPolicy
      • RetryPolicyBase
      • RetryTransientArgs
      • TransientDetector
      • TransientException
    • Neon.Roslyn
      • DisplayFormat
      • DocumentationComment
      • DocumentationItem
      • MetadataLoadContext
      • RoslynAssembly
      • RoslynConstructorInfo
      • RoslynCustomAttributeData
      • RoslynExtensions
      • RoslynFieldInfo
      • RoslynMethodInfo
      • RoslynParameterInfo
      • RoslynPropertyInfo
      • RoslynType
      • SharedUtilities
    • Neon.Roslyn.Xunit
      • AdditionalSourceText
      • CompilationOptions
      • CompilationOptionsProvider
      • TestCompilation
      • TestCompilationAssertions
      • TestCompilationBuilder
      • TestCompilationBuilderExtensions
      • TestCompilationExtensions
    • Neon.SSH
      • CommandBundle
      • CommandFile
      • CommandResponse
      • HostFolders
      • IBashCommandFormatter
      • ILinuxSshProxy
      • LinuxDiskInfo
      • LinuxDiskPartition
      • LinuxSshProxy
      • LinuxSshProxy<TMetadata>
      • NamespaceDoc
      • RemoteCommandException
      • RunOptions
      • SshCredentials
      • SshExtensions
      • SshProxyException
    • Neon.Service
      • LogMetricsProcessor
      • MetricsMode
      • MetricsOptions
      • NeonService
      • NeonServiceOptions
      • NeonServiceStatus
      • OtelConfigExtensions
      • OtlpCollectorChecker
      • ProcessTerminator
      • ServiceApiContact
      • ServiceApiInfo
      • ServiceApiLicense
      • ServiceDependencies
      • ServiceDescription
      • ServiceEndpoint
      • ServiceEndpointProtocol
      • ServiceEndpoints
      • ServiceMap
    • Neon.SignalR
      • DependencyInjectionExtensions
      • DnsCache
      • GroupAction
      • GroupCommand
      • IDnsCache
      • Invocation
      • NatsHubLifetimeManager<THub>
      • ProxyConfig
      • ServiceCollectionExtensions
      • ServiceDiscovey
      • SignalrProxyMiddleware
      • SignalrProxyMiddlewareExtensions
      • TracerProviderBuilderExtensions
    • Neon.Tailwind
      • ClickOffEventHandler
      • ComponentEventArgs<TSender>
      • ComponentEventArgs<TSender, TEventArgs>
      • DisclosureState
      • EventHandlerComponentBase<TComponent>
      • HeadlessButton
      • HeadlessDialog
      • HeadlessDialogPanel
      • HeadlessDisclosure
      • HeadlessDisclosureButton
      • HeadlessDisclosurePanel
      • HeadlessListboxButton<TValue>
      • HeadlessListboxLabel<TValue>
      • HeadlessListboxOption<TValue>
      • HeadlessListboxOptions<TValue>
      • HeadlessListbox<TValue>
      • HeadlessMenu
      • HeadlessMenuButton
      • HeadlessMenuItem
      • HeadlessMenuItems
      • HeadlessSwitch
      • HeadlessSwitchGroup
      • HeadlessSwitchLabel
      • IPortalBinder
      • KeyDownEventHandler
      • KeyboardKey
      • ListboxFocus
      • ListboxState
      • MenuFocus
      • MenuState
      • Portal
      • PortalBinder
      • PortalContent
      • SearchAssistant
      • TailwindExtensions
      • Transition
      • TransitionGroup
      • TransitionState
    • Neon.Tasks
      • Async
      • AsyncAutoResetEvent
      • AsyncManualResetEvent
      • AsyncMutex
      • AsyncPeriodicTask
      • AsyncReaderWriterLock
      • AsyncReentrantMutex
      • AsyncTimer
      • IAsyncFuture
      • IAsyncFuture<T>
      • NonDisposableTask
      • NonDisposableTask<T>
      • SyncContext
      • SyncContextMode
    • Neon.Temporal
      • ActivityHelper
      • ActivityLogEnricher
      • TemporalEnricherTagNames
      • WorkflowLogEnricher
    • Neon.Time
      • GatedTimer
      • GoDuration
      • PolledTimer
      • RecurringTimer
      • RecurringTimerType
      • SysTime
      • TimeOfDay
    • Neon.WSL
      • Wsl2Proxy
    • Neon.Web
      • AesProtector
      • DataProtectionExtensions
      • NeonController
      • NeonControllerBase
      • RoundTripJsonInputFormatter
      • RoundTripJsonOutputFormatter
      • TracerProviderBuilderExtensions
      • WebHelper
    • Neon.WinTTY
      • ConsoleTTY
    • Neon.Windows
      • MEMORYSTATUSEX
      • PowerShellException
      • Win32
    • Neon.XenServer
      • IXenClient
      • XenClient
      • XenClient.MachineOperations
      • XenClient.StorageOperations
      • XenClient.TemplateOperations
      • XenException
      • XenHostInfo
      • XenObject
      • XenResponse
      • XenStorageRepository
      • XenTempIso
      • XenTemplate
      • XenVirtualDisk
      • XenVirtualMachine
      • XenVmPowerState
    • Neon.Xunit
      • AnsiblePlayResults
      • AnsiblePlayer
      • AnsibleTaskResult
      • AspNetFixture
      • BasicFixture
      • CodeFixture
      • CollectionComparer<T>
      • ComposedFixture
      • ContainerFixture
      • ContainerLimits
      • DockerComposeFixture
      • DockerFixture
      • DockerFixture.ConfigInfo
      • DockerFixture.ContainerInfo
      • DockerFixture.NetworkInfo
      • DockerFixture.SecretInfo
      • DockerFixture.ServiceInfo
      • DockerFixture.StackDefinition
      • DockerFixture.StackInfo
      • DockerFixture.StackService
      • EnvironmentFixture
      • HostsFixture
      • ITestFixture
      • IncompatibleServiceException
      • MaintainerFactAttribute
      • MaintainerTheoryAttribute
      • MockHttpServer
      • MockHttpServerExtensions
      • NatsFixture
      • NatsStreamingFixture
      • NeonServiceFixture<TService>
      • PlatformFactAttribute
      • RepeatAttribute
      • TargetPlatforms
      • TestArea
      • TestCollection
      • TestContext
      • TestFixture
      • TestFixtureStatus
      • TestHelper
      • TestHttpClient
      • TestOutputWriter
      • TestTrait
      • XunitExtensions
    • Neon.Xunit.YugaByte
      • YugaByteFixture
    • Neon.YugaByte
      • YugaByteHelper

    Class TestHelper

    Misc local unit test helpers.

    Inheritance
    object
    TestHelper
    Namespace: Neon.Xunit
    Assembly: Neon.Xunit.dll
    Syntax
    public static class TestHelper

    Fields

    ClusterTestingVariable

    The presence of this environment variable indicates that NEONKUBE cluster based unit tests should be enabled.

    Declaration
    public const string ClusterTestingVariable = "NEON_CLUSTER_TESTING"
    Field Value
    Type Description
    string

    IsClusterTestingEnabled

    Indicates whether NEONKUBE cluster based testing is enabled by the presence of the NEON_CLUSTER_TESTING environment variable.

    Declaration
    public static bool IsClusterTestingEnabled
    Field Value
    Type Description
    bool

    Properties

    NeonForgeTestAssetsFolder

    Returns the path to the NEONFORGE project test assets folder. This folder is used to hold various assets required by some NEONFORGE unit tests.

    Declaration
    public static string NeonForgeTestAssetsFolder { get; }
    Property Value
    Type Description
    string
    Exceptions
    Type Condition
    NotSupportedException

    Thrown when the development environment is not fully configured.

    Methods

    AssertEqualLines(string, string)

    Compares two strings such that platform line ending differences will be ignored. This works by removing any embedded carriage returns before performing the comparision.

    Declaration
    public static void AssertEqualLines(string expected, string actual)
    Parameters
    Type Name Description
    string expected

    The expected value.

    string actual

    The actual valut.

    Exceptions
    Type Condition
    AssertException

    Thrown when the strings are not equal after removing CR characters.

    AssertEquivalent<T>(IEnumerable<T>, IEnumerable<T>)

    Ensures that two enumerations contain the same items, possibly in different orders. This is similar to Xunit collection comparison assert method but it doesn't enforce the item order. This uses the default equality comparer.

    Declaration
    public static void AssertEquivalent<T>(IEnumerable<T> expected, IEnumerable<T> collection)
    Parameters
    Type Name Description
    IEnumerable<T> expected

    The expected items.

    IEnumerable<T> collection

    The collection being tested.

    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    AssertException

    Thrown on failure.

    AssertEquivalent<T>(IEnumerable<T>, IEnumerable<T>, IEqualityComparer<T>)

    Ensures that two enumerations contain the same items, possibly in different orders. This is similar to Xunit collection comparison assert method but it doesn't enforce the item order. This uses a custom equality comparer.

    Declaration
    public static void AssertEquivalent<T>(IEnumerable<T> expected, IEnumerable<T> collection, IEqualityComparer<T> comparer)
    Parameters
    Type Name Description
    IEnumerable<T> expected

    The expected items.

    IEnumerable<T> collection

    The collection being tested.

    IEqualityComparer<T> comparer

    The comparer used to equate objects in the collection with the expected object

    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    AssertException

    Thrown on failure.

    AssertEquivalent<TKey, TValue>(IDictionary<TKey, TValue>, IDictionary<TKey, TValue>)

    Ensures that two dictionaries contain the same items using the default equality comparer.

    Declaration
    public static void AssertEquivalent<TKey, TValue>(IDictionary<TKey, TValue> expected, IDictionary<TKey, TValue> dictionary)
    Parameters
    Type Name Description
    IDictionary<TKey, TValue> expected

    The expected items.

    IDictionary<TKey, TValue> dictionary

    The collection being tested.

    Type Parameters
    Name Description
    TKey

    Specifies the dictionary key type.

    TValue

    Specifies the dictionary value type.

    Exceptions
    Type Condition
    AssertException

    Thrown on failure.

    AssertEquivalent<TKey, TValue>(IDictionary<TKey, TValue>, IDictionary<TKey, TValue>, IEqualityComparer<TValue>)

    Ensures that two dictionaries contain the same items using an equality comparer.

    Declaration
    public static void AssertEquivalent<TKey, TValue>(IDictionary<TKey, TValue> expected, IDictionary<TKey, TValue> dictionary, IEqualityComparer<TValue> comparer)
    Parameters
    Type Name Description
    IDictionary<TKey, TValue> expected

    The expected items.

    IDictionary<TKey, TValue> dictionary

    The collection being tested.

    IEqualityComparer<TValue> comparer

    The equality comparer to be used.

    Type Parameters
    Name Description
    TKey

    Specifies the dictionary key type.

    TValue

    Specifies the dictionary value type.

    Exceptions
    Type Condition
    AssertException

    Thrown on failure.

    AssertNotEqualLines(string, string)

    Compares two strings such that platform line ending differences will be ignored. This works by removing any embedded carriage returns before performing the comparision.

    Declaration
    public static void AssertNotEqualLines(string expected, string actual)
    Parameters
    Type Name Description
    string expected

    The expected value.

    string actual

    The actual valut.

    Exceptions
    Type Condition
    AssertException

    Thrown when the strings are equal after removing CR characters.

    AssertNotEquivalent<T>(IEnumerable<T>, IEnumerable<T>)

    Ensures that two enumerations are not equivalent, using the default equality comparer.

    Declaration
    public static void AssertNotEquivalent<T>(IEnumerable<T> expected, IEnumerable<T> collection)
    Parameters
    Type Name Description
    IEnumerable<T> expected

    The expected items.

    IEnumerable<T> collection

    The collection being tested.

    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    AssertException

    Thrown on failure.

    AssertNotEquivalent<T>(IEnumerable<T>, IEnumerable<T>, IEqualityComparer<T>)

    Ensures that two enumerations are not equivalent, using a custom equality comparer.

    Declaration
    public static void AssertNotEquivalent<T>(IEnumerable<T> expected, IEnumerable<T> collection, IEqualityComparer<T> comparer)
    Parameters
    Type Name Description
    IEnumerable<T> expected

    The expected items.

    IEnumerable<T> collection

    The collection being tested.

    IEqualityComparer<T> comparer

    The comparer used to equate objects in the collection with the expected object

    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    AssertException

    Thrown on failure.

    AssertNotEquivalent<TKey, TValue>(IDictionary<TKey, TValue>, IDictionary<TKey, TValue>)

    Ensures that two dictionaries do not contain the same items using the default equality comparer.

    Declaration
    public static void AssertNotEquivalent<TKey, TValue>(IDictionary<TKey, TValue> expected, IDictionary<TKey, TValue> dictionary)
    Parameters
    Type Name Description
    IDictionary<TKey, TValue> expected

    The expected items.

    IDictionary<TKey, TValue> dictionary

    The collection being tested.

    Type Parameters
    Name Description
    TKey

    Specifies the dictionary key type.

    TValue

    Specifies the dictionary value type.

    Exceptions
    Type Condition
    AssertException

    Thrown on failure.

    AssertNotEquivalent<TKey, TValue>(IDictionary<TKey, TValue>, IDictionary<TKey, TValue>, IEqualityComparer<TValue>)

    Ensures that two dictionaries do not contain the same items using an equality comparer.

    Declaration
    public static void AssertNotEquivalent<TKey, TValue>(IDictionary<TKey, TValue> expected, IDictionary<TKey, TValue> dictionary, IEqualityComparer<TValue> comparer)
    Parameters
    Type Name Description
    IDictionary<TKey, TValue> expected

    The expected items.

    IDictionary<TKey, TValue> dictionary

    The collection being tested.

    IEqualityComparer<TValue> comparer

    The equality comparer to be used.

    Type Parameters
    Name Description
    TKey

    Specifies the dictionary key type.

    TValue

    Specifies the dictionary value type.

    Exceptions
    Type Condition
    AssertException

    Thrown on failure.

    AssertThrowsAsync<TException>(Func<Task>)

    Verifies that an asynchronous action throws a TException or an AggregateException that contains TException.

    Declaration
    public static Task AssertThrowsAsync<TException>(Func<Task> action) where TException : Exception
    Parameters
    Type Name Description
    Func<Task> action

    The test action.

    Returns
    Type Description
    Task

    The tracking Task.

    Type Parameters
    Name Description
    TException

    The required exception type.

    AssertThrows<TException>(Action)

    Verifies that an action throws a TException or an AggregateException that contains TException.

    Declaration
    public static void AssertThrows<TException>(Action action) where TException : Exception
    Parameters
    Type Name Description
    Action action

    The test action.

    Type Parameters
    Name Description
    TException

    The required exception type.

    Exceptions
    Type Condition
    AssertException

    Thrown when no exception was thrown or the exception thrown had an unexpected type.

    GetUbuntuTestVhdxPath()

    Returns the path to a Ubuntu VHDX manifest suitable for basic unit testing. This will be located in the NeonForgeTestAssetsFolder and will be downloaded from S3 if it's not already present.

    Declaration
    public static string GetUbuntuTestVhdxPath()
    Returns
    Type Description
    string

    Path to the VHDX file.

    Remarks

    This is simply a copy of the base image used for constructing NEONKUBE node images and is Ubuntu 22.04 with these key changes (amongst others):

    • User credentials are: sysadmin/sysadmin0000
    • sudo password prompting is disabled.
    • sshd is enabled.
    • SNAP has been removed.
    • unzip is installed to support LinuxSshProxy commands.

    ResetDocker(Type, bool)

    Resets Docker state by removing all containers, volumes, networks and optionally the Docker image cache. This is useful ensuring that Docker is in a known state. This also disables swarm mode.

    Declaration
    public static void ResetDocker(Type testClass, bool pruneImages = false)
    Parameters
    Type Name Description
    Type testClass

    Specifies the current test class or pass null to force the reset).

    bool pruneImages

    Optionally prunes the Docker image cache.

    Remarks

    This method works by comparing the testClass passed with any previous test class passed. The method only resets the Docker state when the test class changes. This prevents Docker from being reset when every test in the same class runs (which will probably break tests).

    note

    This does not support multiple test classes performing parallel Docker operations.

    RunFixture<T>(params object[])

    Used to run a TestFixture outside of a unit test.

    Declaration
    public static void RunFixture<T>(params object[] args) where T : class
    Parameters
    Type Name Description
    object[] args

    Optional parameters that will be passed to the constructor after the fixture parameter. Note that the number of parameters and their types must match the constructor parameters after the fixture one.

    Type Parameters
    Name Description
    T

    Specifies the test type.

    Remarks

    This is often used to run a NeonService using NeonServiceFixture<TService> or a collection of NeonService instances for debugging purposes using a combination of a ComposedFixture with NeonServiceFixture<TService> sub-fixtures. But, this can also be used for any ITestFixture implementation.

    You'll need to implement a test class that derives from a Xunit.IClassFixture<TFixture> implementation and optionally implements IDisposable. You'll pass your test type as T. Your test class must include a public constructor that accepts a single parameter with the test fixture type and a public method with no parameters called public void Run().

    This will look something like:

    public class MyTestRunner : IClassFixture<ComposedFixture>
    {
        private ComposedFixture                     composedFixture;
        private NatsFixture                         natsFixture;
        private NeonServiceFixture<QueueService>    queueServiceFixture;
    
    public MyTestRunner(ComposedFixture fixture)
    {
        this.composedFixture = fixture;
    
        composedFixture.Start(
            () =>
            {
                composedFixture.AddFixture("nats", new NatsFixture(),
                    natsFixture =>
                    {
                       natsFixture.StartAsComposed();
                    });
    
                composedFixture.AddServiceFixture("queue-service", new NeonServiceFixture<QueueService>(), () => CreateQueueService());
            });
    
        this.natsFixture         = (NatsFixture)composedFixture["nats"];
        this.queueServiceFixture = (NeonServiceFixture<QueueService>)composedFixture["queue-service"];
    }
    
    public void Run()
    {
        // The runner will stop when this method returns.  You can
        // also use this as an opportunity to perform any initialization.
        // For this example, we're just going to spin slowly forever.
    
        while (true)
        {
            System.Threading.Thread.Sleep(10000);
        }
    }
    

    }

    This method performs these steps:

    1. Perform a runtime check to verify that T has a public constructor that accepts a single parameter of type T as well as any additional parameters.
    2. Perform a runtime check to ensure that T has a public void Run() method.
    3. Instantiate an instance of the test fixture specified by Xunit.IClassFixture<TFixture>.
    4. Instantiate an instance of T, passing the test fixture just created as the parameter.
    5. Call the Run() method and wait for it to return.
    6. Dispose the test fixture.
    7. Call Dispose(), if implemented by the test class.
    8. The method returns.

    TempFolder(string, string)

    Creates and populates a temporary test folder with a test file.

    Declaration
    public static TempFolder TempFolder(string filename, string data)
    Parameters
    Type Name Description
    string filename

    The file data.

    string data

    The file name

    Returns
    Type Description
    TempFolder

    The TempFolder(string, string).

    Remarks
    note

    Ensure that the TempFolder(string, string) returned is disposed so it and any files within will be deleted.

    In this article
    Back to top © Copyright 2005-2023 by NEONFORGE LLC