Src/Idioms/NullReferenceBehaviorExpectation.cs
/// <summary>
/// Verifies that the command behaves correct when invoked with a null argument.
/// </summary>
/// <param name="command">The command whose behavior must be examined.</param>
/// <remarks>
/// <para>
/// The Verify method attempts to invoke the <paramref name="command" /> instance's
/// <see cref="IGuardClauseCommand.Execute" /> with <see langword="null" />. The expected
/// result is that this action throws an <see cref="ArgumentNullException" /> with proper parameter name, 
/// in which case the expected behavior is considered verified. If any other exception is thrown, or
/// if no exception is thrown at all, the verification fails and an exception is thrown.
/// </para>
/// <para>
/// The behavior is only asserted if the command's
/// <see cref="IGuardClauseCommand.RequestedType" /> is nullable. In case of value types,
/// no action is performed.
/// </para>
/// </remarks>
Verifies that the command behaves correct when invoked with a null argument.
Verifies that the command behaves correct when invoked with a null argument .
public void Verify(IGuardClauseCommand command)
        {
            if (command == null) throw new ArgumentNullException(nameof(command));
            if (!command.RequestedType.IsClass
                && !command.RequestedType.IsInterface)
            {
                return;
            }
            try
            {
                command.Execute(null);
            }
            catch (ArgumentNullException e)
            {
                if (string.Equals(e.ParamName, command.RequestedParameterName, StringComparison.Ordinal))
                    return;
                throw command.CreateException("null", e);
            }
            catch (Exception e)
            {
                throw command.CreateException("null", e);
            }
            throw command.CreateException("null");
        }
public void Verify ( IGuardClauseCommand command ) { if ( command == null ) throw new ArgumentNullException ( nameof ( command ) ) ; if ( ! command . RequestedType . IsClass && ! command . RequestedType . IsInterface ) { return ; } try { command . Execute ( null ) ; } catch ( ArgumentNullException e ) { if ( string . Equals ( e . ParamName , command . RequestedParameterName , StringComparison . Ordinal ) ) return ; throw command . CreateException ( " " , e ) ; } catch ( Exception e ) { throw command . CreateException ( " " , e ) ; } throw command . CreateException ( " " ) ; }
Verifies that the command behaves correct when invoked with a null argument.
Verifies that the command behaves correct when invoked with a null argument .
command
IGuardClauseCommand
The command whose behavior must be examined.
The command whose behavior must be examined .
remarks
The Verify method attempts to invoke the  instance's
with . The expected
result is that this action throws an  with proper parameter name,
in which case the expected behavior is considered verified. If any other exception is thrown, or
if no exception is thrown at all, the verification fails and an exception is thrown.

The behavior is only asserted if the command's
is nullable. In case of value types,
no action is performed.
The Verify method attempts to invoke the instance ' s with . The expected result is that this action throws an with proper parameter name in which case the expected behavior is considered verified . If any other exception is thrown or if no exception is thrown at all the verification fails and an exception is thrown . The behavior is only asserted if the command ' s is nullable . In case of value types no action is performed .