基本仕様で Behaves_like を指定して、特定のメソッドが仮想としてマークされるようにしたいと考えています。このようなもの:
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;
}
ただし、テスト ランナーはこれを検出しません。コマンド ハンドラーのすべての仕様で ehaves_like を指定するのは、大きな PITA になると思います。これは可能ですか?そうでない場合、これは望ましい動作ですか?
更新: 応答が遅くなって申し訳ありません。失敗した仕様は次のとおりです。
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();
}