public void Global_Middleware_Terminates() { _mockInteractor = Substitute.For <IInteractor <MockUseCase, IMockOutputPort> >(); _handlerResolver.ResolveInteractor <MockUseCase, IMockOutputPort>(Arg.Any <MockUseCase>()).Returns(_mockInteractor); var globalMiddleware = Substitute.For <IMiddleware>(); globalMiddleware.Execute( Arg.Any <MockUseCase>(), d => Task.FromResult(new UseCaseResult(true)), Arg.Any <CancellationToken>()) .ReturnsForAnyArgs(x => new UseCaseResult(true)) .AndDoes(x => { }); IReadOnlyList <IMiddleware> globalPipeline = new List <IMiddleware> { globalMiddleware }; _handlerResolver.ResolveGlobalMiddleware().Returns(globalPipeline); _interactorHub.Execute(new MockUseCase(), (IMockOutputPort) new MockOutputPort()); _mockInteractor.DidNotReceive().Execute( Arg.Any <MockUseCase>(), Arg.Any <MockOutputPort>(), Arg.Any <CancellationToken>()); }