MockerTestBase<(Of <(<'TComponent>)>)>..::..TestConstructorParameters Method (Action<(Of <(<'Action, String, String>)>)>, Nullable<(Of <(<'Func<(Of <(<'ParameterInfo, Nullable<(Of <(<'Object>)>)>>)>)>>)>)>, Nullable<(Of <(<'Func<(Of <(<'ParameterInfo, Nullable<(Of <(<'Object>)>)>>)>)>>)>)>)

Tests the constructor parameters.

Namespace:  FastMoq
Assembly:  FastMoq.Core (in FastMoq.Core.dll)

Syntax


protected void TestConstructorParameters(
	Action<Action, string, string> createAction,
	Nullable<Func<ParameterInfo, Nullable<Object>>> defaultValue,
	Nullable<Func<ParameterInfo, Nullable<Object>>> validValue
)
Protected Sub TestConstructorParameters ( _
	createAction As Action(Of Action, String, String), _
	defaultValue As Nullable(Of Func(Of ParameterInfo, Nullable(Of Object))), _
	validValue As Nullable(Of Func(Of ParameterInfo, Nullable(Of Object))) _
)
protected:
void TestConstructorParameters(
	Action<Action^, String^, String^>^ createAction, 
	Nullable<Func<ParameterInfo^, Nullable<Object^>>^> defaultValue, 
	Nullable<Func<ParameterInfo^, Nullable<Object^>>^> validValue
)

Parameters

createAction
Type: Action<(Of <(<'Action, String, String>)>)>
The create action.
defaultValue
Type: Nullable<(Of <(<'Func<(Of <(<'ParameterInfo, Nullable<(Of <(<'Object>)>)>>)>)>>)>)>
The default value.
validValue
Type: Nullable<(Of <(<'Func<(Of <(<'ParameterInfo, Nullable<(Of <(<'Object>)>)>>)>)>>)>)>
The valid value.

Examples


CreateComponent allows creating the component when desired, instead of in the base class constructor.
C#
[Fact]
public void Service_NullArgChecks() => TestConstructorParameters((action, constructorName, parameterName) =>
{
    output?.WriteLine($"Testing {constructorName}\n - {parameterName}");

    action
        .Should()
        .Throw<ArgumentNullException>()
        .WithMessage($"*{parameterName}*");
});

[Fact]
public void Service_NullArgChecks() => TestConstructorParameters((action, constructorName, parameterName) =>
    {
        output?.WriteLine($"Testing {constructorName}\n - {parameterName}");

        action
            .Should()
            .Throw<ArgumentNullException>()
            .WithMessage($"*{parameterName}*");
    },
    info =>
    {
        return info switch
        {
            { ParameterType: { Name: "string" }} => string.Empty,
            { ParameterType: { Name: "int" }} => -1,
            _ => default,
        };
    },
    info =>
    {
        return info switch
        {
            { ParameterType: { Name: "string" }} => "Valid Value",
            { ParameterType: { Name: "int" }} => 22,
            _ => Mocks.GetObject(info.ParameterType),
        };
    }
);