특정 메서드가 가상으로 표시되도록하려면 기본 사양에 Behaves_like를 지정하고 싶습니다. 다음과 같은 내용 :Behaves_like 사용 <TBehavior> 기본 클래스에
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();
}
나는 그렇게하는 것을 선호합니다. 그러나 그것은 작동하지 않습니다. resharper 테스트 러너에 표시되지 않으며 명령 줄에서 실행되지 않습니다. –
나는이 권리를 얻을 수 있도록하기 위해 : 기본 클래스의'It' 필드가 당신을 위해 작동하지 않습니까? 전체 코드 (동작 사양 포함)를 어딘가에 게시 할 수 있습니까? –
내 게시물이 업데이트되었습니다.보세요. 감사. –