I am sure that you are looking for Behavior (see also article line test with article behavior ). You define the behavior that each implementation must satisfy ( It fields) in a special class that share SUT and supporting fields (if necessary).
[Behaviors] public class DeferredExecutionProcessor { It should_not_have_enumerated_the_original_samples = () => { _.Original.DidNotReceive().GetEnumerator(); ((IEnumerable)_.Original).DidNotReceive().GetEnumerator(); }; protected static Context _; }
Each of your implementations must state that they behave like this special class. You already had a rather complex base class with general setup and behavior, so I will use it (I prefer a simpler, more explicit setup).
public abstract class AudioProcessorContext<TSutFactory> where TSutFactory : ISutFactory<IAudioProcessor>, new() {
Your base class defines the general setting (capturing the context enumeration), behavior (processing using a specific impl using a type parameter), and even declaring a behavior field (again, thanks to the generic type parameter, this will be done for each specific one).
[Subject("Audio Processor Impl 1")] public class when_impl1_processes_audio : AudioProcessorContext<AudioProcessorImpl1Factory> { Because of = () => Sut.Process(_.Original); Behaves_like<DeferredExecutionProcessor> specs; } [Subject("Audio Processor Impl 2")] public class when_impl2_processes_audio : AudioProcessorContext<AudioProcessorImpl2Factory> { Because of = () => Sut.Process(_.Original); Behaves_like<DeferredExecutionProcessor> specs; } [Subject("Audio Processor Impl 3")] public class when_impl3_processes_audio : AudioProcessorContext<AudioProcessorImpl3Factory> { Because of = () => Sut.Process(_.Original); Behaves_like<DeferredExecutionProcessor> specs; }
In addition, you will get output for each of the It fields for each of the implementation classes. Thus, your context / specification reports will be completed.
Anthony mastrean
source share