/// <summary> /// Adds the interceptor. The interceptor will be called on every /// command execution. /// </summary> /// <remarks> /// When the interceptor was already added to this command service, it /// is skipped. That means that it is not added twice. /// </remarks> /// <param name="interceptor">The interceptor to add.</param> public virtual void AddInterceptor(ICommandServiceInterceptor interceptor) { if (!_interceptors.Contains(interceptor)) { _interceptors.Add(interceptor); } }
public void Setup() { var service = new CommandService(); ExecutorForCommandWithExecutor = MockRepository.GenerateMock<ICommandExecutor<CommandWithExecutor>>(); ExecutorForCommandWithExecutorThatThrowsException = MockRepository.GenerateMock<ICommandExecutor<CommandWithExecutorThatThrowsException>>(); Interceptor1 = MockRepository.GenerateMock<ICommandServiceInterceptor>(); Interceptor2 = MockRepository.GenerateMock<ICommandServiceInterceptor>(); ExecutorForCommandWithExecutorThatThrowsException.Stub(e=>e.Execute(null)).IgnoreArguments().Throw(new Exception()); service.RegisterExecutor(ExecutorForCommandWithExecutor); service.RegisterExecutor(ExecutorForCommandWithExecutorThatThrowsException); service.AddInterceptor(Interceptor1); service.AddInterceptor(Interceptor2); TheService = service; }
public void Setup() { var service = new CommandService(); ExecutorForCommandWithExecutor = MockRepository.GenerateMock <ICommandExecutor <CommandWithExecutor> >(); ExecutorForCommandWithExecutorThatThrowsException = MockRepository.GenerateMock <ICommandExecutor <CommandWithExecutorThatThrowsException> >(); Interceptor1 = MockRepository.GenerateMock <ICommandServiceInterceptor>(); Interceptor2 = MockRepository.GenerateMock <ICommandServiceInterceptor>(); ExecutorForCommandWithExecutorThatThrowsException.Stub(e => e.Execute(null)).IgnoreArguments().Throw(new Exception()); service.RegisterExecutor(ExecutorForCommandWithExecutor); service.RegisterExecutor(ExecutorForCommandWithExecutorThatThrowsException); service.AddInterceptor(Interceptor1); service.AddInterceptor(Interceptor2); TheService = service; }
/// <summary> /// Removes the interceptor. The interceptor will not be called anymore. /// </summary> /// <param name="interceptor">The interceptor to remove.</param> public virtual void RemoveInterceptor(ICommandServiceInterceptor interceptor) { _interceptors.Remove(interceptor); }