/// <summary> /// Executes the guard. /// </summary> /// <param name="argument">The state machine event argument.</param> /// <returns>Result of the guard execution.</returns> public bool Execute(object argument) { if (argument != null && !(argument is T)) { throw new ArgumentException(GuardHoldersExceptionMessages.CannotCastArgumentToGuardArgument(argument, this.Describe())); } return(this.guard((T)argument)); }
public void ExecuteWhenPassingWrongTypeThenException() { const int Argument = 4; Action action = () => this.testee.Execute(Argument); action .ShouldThrow <ArgumentException>() .WithMessage(GuardHoldersExceptionMessages.CannotCastArgumentToGuardArgument(Argument, this.testee.Describe())); }