I would like to specify a Behaves_like on a base specification to ensure that a particular method is marked as virtual. Something like this:
public abstract class command_handler_context<TCommandHandler, TCommand>
: abstract_context<TCommandHandler>
where TCommandHandler : ICommandHandler<TCommand>
where TCommand : ICommand, new()
{
protected static TCommand Command;
private Establish context = () =>
{
Command = new TCommand();
};
private Because of = () => SubjectUnderTest.Execute(Command);
private Behaves_like<ExecuteMethodOverridableBehavior<TCommandHandler>> an_overridable_execute_method;
}
However the test runner does not pick this up. I think it would be a major PITA to specify ehaves_like on every single spec for a command handler. Is this possible? If not, is this a desired behavior?
Update: Sorry about the late response, here is the failing spec:
public abstract class context_base
{
protected static bool Result;
protected static bool RanOnBaseClass;
private Because of = () => { Result = true; };
private It should_be_true = () =>
{
RanOnBaseClass = true;
Result.ShouldBeTrue();
};
}
public class when_using_behaviors_on_a_base_class
: context_base
{
private It should_run_specs_on_the_base_class = () => RanOnBaseClass.ShouldBeTrue();
}