Mittons.Fixtures 1.0.0-rc.2

This is a prerelease version of Mittons.Fixtures.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Mittons.Fixtures --version 1.0.0-rc.2
NuGet\Install-Package Mittons.Fixtures -Version 1.0.0-rc.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mittons.Fixtures" Version="1.0.0-rc.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mittons.Fixtures --version 1.0.0-rc.2
#r "nuget: Mittons.Fixtures, 1.0.0-rc.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Mittons.Fixtures as a Cake Addin
#addin nuget:?package=Mittons.Fixtures&version=1.0.0-rc.2&prerelease

// Install Mittons.Fixtures as a Cake Tool
#tool nuget:?package=Mittons.Fixtures&version=1.0.0-rc.2&prerelease

Mittons.Fixtures

Mittons.Fixtures is a framework for standing up testing environments via fixtures, which can be integrated into other testing frameworks.

Introduction

This project was created to allow developers to declare their environments in a fixture using attributes to define service settings, allowing the testing framework to spin up the full environment. This saves developers the need to create pre/post test scripts that build/teardown the testing environment, and keeps the environment definition closer to the actual tests.

Documentation

Currently, this library uses Docker for spinning up the test environment. To define an environment, you would create a class extending the DockerEnvironmentFixture, and define all the containers you wish to stand up. When you define a fixture, the following attributes can be applied:

  • [Run(string)] - Defines the details for the run, this currently only accepts a string representing an environment variable from which to get an id to apply to all resources created in the test environment. This allows you to use that identifier for post-test cleanup action in the instance the tests are cancelled prematurely and normal cleanup behavior does not occur.
  • [Network(string)] - Defines a Docker network to create.

Supported container types are:

  • Container: This is the base class for all containers, so if an abstraction for your container type doesn't exist, this is where you would start. All containers support the following attributes:
    • [Image(string)] - Defines the image used to create the container.
    • [Command(string)] - Defines the command Docker runs once the container is started.
    • [HealthCheck(Disabled = boolean, Command = string, Interval = TimeSpan, Timeout = TimeSpan, StartPeriod = TimeSpan, Retries = int)] - Defines the settings for Docker to perform health checks on the container.
    • [NetworkAlias(string, string)] - Defines a Docker network to which the container should be attached, and the alias by which other containers on the network can communicate with it.
  • SftpContainer: Extending Container, this adds extra convenience functionality specific to spinning up and Sftp server. SftpContainers are built using the atmoz/sftp:alpine image, and since that assumes certain behaviors, [Image] attributes will be ignored for these containers. In addtion to the normal Container attributes, SftpContainer supports the following attributes:
    • [SftpUserAccout(string, string)] - Adds an account to the sftp server using the provided username and password.

A good reference on how do define an environment can be found in the Mittons.Fixtures.Example project, which is designed to demo this library.

Example

Note: This example leverages the SSH.NET library

public class ReportingEnvironmentFixture : DockerEnvironmentFixture
{
    [SftpUserAccount("admin", "securepassword")]
    [SftpUserAccount("tswift", "hatersgonnahate")]
    public SftpContainer SftpContainer { get; set; }
}

public class ConnectionSettingsTests : IClassFixture<ReportingEnvironmentFixture>
{
    private readonly ReportingEnvironmentFixture _reportingEnvironment;

    public ConnectionSettingsTests(ReportingEnvironmentFixture reportingEnvironment)
    {
        _reportingEnvironment = reportingEnvironment;
    }

    [Fact]
    public void Connect_WhenUsingTheAdminCredentials_ExpectASuccessfulConnection()
    {
        // Arrange
        var connectionSettings = _reportingEnvironment.SftpContainer.SftpConnectionSettings.Single(x => x.Key == "admin").Value;

        var connectionInfo = new ConnectionInfo(
                connectionSettings.Host,
                connectionSettings.Port,
                connectionSettings.Username,
                new PasswordAuthenticationMethod(connectionSettings.Username, connectionSettings.Password)
            );

        // Act
        using var client = new SftpClient(connectionInfo);

        client.Connect();

        // Assert
        Assert.True(client.IsConnected);
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-rc.4 137 5/8/2022
1.0.0-rc.3 126 4/17/2022
1.0.0-rc.2 125 4/16/2022
1.0.0-rc.1 122 4/9/2022
1.0.0-prerelease.3 118 4/9/2022
1.0.0-prerelease.2 115 4/7/2022
1.0.0-prerelease 121 4/6/2022