Carna

Parameter Attribute

This attribute specifies a field, property, or method as a parameter to child fixtures.

The value specified by this attribute is set to a parameter of a child fixture's constructor whose name is equal to the name that is specified by this attribute. If the name property of this attribute is not specified, a name of a field, property, or method is used.

The available property is as follows.

Property Description
Name Specifies a parameter name that is set to a child fixture's constructor.

For example:

[Specification]
class CustomerSpec
{
    [Parameter("path")]
    string WorkingDirectoryPath { get; }

    public CustomerSpec() => WorkingDirectoryPath = Path.GetTempPath();

    [Context]
    class Context01
    {
        string DirectoryPath { get; }

        public Context01(string path) => DirectoryPath = path;
    }

    [Context]
    class Context02
    {
        string DirectoryPath { get; }

        public Context02(string path) => DirectoryPath = path;
    }
}