Class MethodInvokeCommand

Namespace: AutoFixture.Idioms
Assembly: AutoFixture.Idioms.dll

Invokes a method.

public class MethodInvokeCommand : IGuardClauseCommand

Inheritance

objectMethodInvokeCommand

Implements

IGuardClauseCommand

Inherited Members

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

MethodInvokeCommand(IMethod, IExpansion<object>, ParameterInfo)

Initializes a new instance of the MethodInvokeCommand class.

public MethodInvokeCommand(IMethod method, IExpansion<object> expansion, ParameterInfo parameterInfo)

Parameters

method IMethod

The method to invoke.

expansion IExpansion<object>

An expansion which is used to transform the single value in the Execute method into an appropriate number of input arguments for the method.

parameterInfo ParameterInfo

The parameter.

Properties

Expansion

Gets the expansion supplied via the constructor.

public IExpansion<object> Expansion { get; }

Property Value

IExpansion<object>

See Also

MethodInvokeCommand.Execute(object)

Method

Gets the method supplied via the constructor.

public IMethod Method { get; }

Property Value

IMethod

ParameterInfo

Gets the parameter supplied via the constructor.

public ParameterInfo ParameterInfo { get; }

Property Value

ParameterInfo

RequestedParameterName

Gets the parameter name of the requested value.

public string RequestedParameterName { get; }

Property Value

string

Remarks

The RequestedParameterName property identifies the parameter name of object which should be supplied to the Object) method - in this case the name of the ParameterInfo.

RequestedType

Gets the type of the requested value.

public Type RequestedType { get; }

Property Value

Type

Remarks

The RequestedType property identifies the type of object which should be supplied to the Object) method - in this case the type of the ParameterInfo.

Methods

CreateException(string)

Creates an exception which communicates that an error occured for a specific input value.

public Exception CreateException(string value)

Parameters

value string

A string representation of the value.

Returns

Exception

An exception which communicates the cause of the error.

Remarks

The value is a string representation of the value supplied to the `Object)` method. Together with the context contained within any implementation of `IGuardClauseCommand` this value can be used to build an exception message.

CreateException(string, Exception)

Creates an exception which communicates that an error occured for a specific input value.

public Exception CreateException(string value, Exception innerException)

Parameters

value string

A string representation of the value.

innerException Exception

The exception that is the cause of the current exception.

Returns

Exception

An exception which communicates the cause of the error.

Remarks

The value is a string representation of the value supplied to the `Object)` method. Together with the context contained within any implementation of `IGuardClauseCommand` this value can be used to build an exception message.

CreateException(string, string, Exception)

Creates an exception which communicates that an error occured for a specific input value.

public Exception CreateException(string value, string customError, Exception innerException)

Parameters

value string

A string representation of the value.

customError string

A custom explanation of the guard clause failure.

innerException Exception

The exception that is the cause of the current exception.

Returns

Exception

An exception which communicates the cause of the error.

Remarks

The value is a string representation of the value supplied to the `Object)` method. Together with the passed customError and context contained within any implementation of `IGuardClauseCommand` this value can be used to build an exception message.

Execute(object)

Invokes the method with the specified value.

public void Execute(object value)

Parameters

value object

The value with wich the method is executed.

Remarks

Invokes `Method` by expanding the single value with the `Expansion`.