Search Results for

    Show / Hide Table of Contents

    Class TestCaseData

    The TestCaseData class represents a set of arguments and other parameter info to be used for a parameterized test case. It is derived from TestCaseParameters and adds a fluent syntax for use in initializing the test case.

    Inheritance
    object
    TestParameters
    TestCaseParameters
    TestCaseData
    TestCaseData<T>
    TestCaseData<T1, T2>
    TestCaseData<T1, T2, T3>
    TestCaseData<T1, T2, T3, T4>
    TestCaseData<T1, T2, T3, T4, T5>
    Implements
    ITestCaseData
    ITestData
    IApplyToTest
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: NUnit.Framework
    Assembly: nunit.framework.dll
    Syntax
    public class TestCaseData : TestCaseParameters, ITestCaseData, ITestData, IApplyToTest

    Constructors

    View Source

    TestCaseData(object?)

    Initializes a new instance of the TestCaseData class.

    Declaration
    public TestCaseData(object? arg)
    Parameters
    Type Name Description
    object arg

    The argument.

    View Source

    TestCaseData(object?, object?)

    Initializes a new instance of the TestCaseData class.

    Declaration
    public TestCaseData(object? arg1, object? arg2)
    Parameters
    Type Name Description
    object arg1

    The first argument.

    object arg2

    The second argument.

    View Source

    TestCaseData(object?, object?, object?)

    Initializes a new instance of the TestCaseData class.

    Declaration
    public TestCaseData(object? arg1, object? arg2, object? arg3)
    Parameters
    Type Name Description
    object arg1

    The first argument.

    object arg2

    The second argument.

    object arg3

    The third argument.

    View Source

    TestCaseData(params object?[]?)

    Initializes a new instance of the TestCaseData class.

    Declaration
    public TestCaseData(params object?[]? args)
    Parameters
    Type Name Description
    object[] args

    The arguments.

    Methods

    View Source

    Explicit()

    Marks the test case as explicit.

    Declaration
    public TestCaseData Explicit()
    Returns
    Type Description
    TestCaseData
    View Source

    Explicit(string)

    Marks the test case as explicit, specifying the reason.

    Declaration
    public TestCaseData Explicit(string reason)
    Parameters
    Type Name Description
    string reason
    Returns
    Type Description
    TestCaseData
    View Source

    Ignore(string)

    Ignores this TestCase, specifying the reason.

    Declaration
    public IgnoredTestCaseData Ignore(string reason)
    Parameters
    Type Name Description
    string reason

    The reason.

    Returns
    Type Description
    IgnoredTestCaseData
    View Source

    Returns(object?)

    Sets the expected result for the test

    Declaration
    public TestCaseData Returns(object? result)
    Parameters
    Type Name Description
    object result

    The expected result

    Returns
    Type Description
    TestCaseData

    A modified TestCaseData

    View Source

    SetArgDisplayNames(params string[]?)

    Sets the list of display names to use as the parameters in the test name.

    Declaration
    public TestCaseData SetArgDisplayNames(params string[]? displayNames)
    Parameters
    Type Name Description
    string[] displayNames
    Returns
    Type Description
    TestCaseData

    The modified TestCaseData instance

    Examples
    TestCaseData testCase = new TestCaseData(args)
        .SetArgDisplayNames("arg1DisplayName", "arg2DisplayName");
    View Source

    SetCategory(string)

    Applies a category to the test

    Declaration
    public TestCaseData SetCategory(string category)
    Parameters
    Type Name Description
    string category
    Returns
    Type Description
    TestCaseData
    View Source

    SetDescription(string)

    Sets the description for the test case being constructed.

    Declaration
    public TestCaseData SetDescription(string description)
    Parameters
    Type Name Description
    string description

    The description.

    Returns
    Type Description
    TestCaseData

    The modified TestCaseData instance.

    View Source

    SetName(string?)

    Sets the name of the test case

    Declaration
    public TestCaseData SetName(string? name)
    Parameters
    Type Name Description
    string name
    Returns
    Type Description
    TestCaseData

    The modified TestCaseData instance

    Remarks

    Consider using SetArgDisplayNames(params string[]?)for setting argument values in the test name. SetArgDisplayNames(params string[]?) allows you to specify the display names for parameters directly without needing to use tokens like {m}.

    View Source

    SetProperty(string, double)

    Applies a named property to the test

    Declaration
    public TestCaseData SetProperty(string propName, double propValue)
    Parameters
    Type Name Description
    string propName
    double propValue
    Returns
    Type Description
    TestCaseData
    View Source

    SetProperty(string, int)

    Applies a named property to the test

    Declaration
    public TestCaseData SetProperty(string propName, int propValue)
    Parameters
    Type Name Description
    string propName
    int propValue
    Returns
    Type Description
    TestCaseData
    View Source

    SetProperty(string, string)

    Applies a named property to the test

    Declaration
    public TestCaseData SetProperty(string propName, string propValue)
    Parameters
    Type Name Description
    string propName
    string propValue
    Returns
    Type Description
    TestCaseData

    Implements

    ITestCaseData
    ITestData
    IApplyToTest
    • View Source
    In this article
    Back to top Generated by DocFX | Copyright (c) 2018- The NUnit Project - Licensed under CC BY-NC-SA 4.0