public async Task Invoke_ShouldCallMiddleware() { var middleware = Substitute.For <IMiddlewareSubstitute>(); middleware .Handle(Arg.Any <Context>(), Arg.Any <RouteFuncAsync>()) .ReturnsForAnyArgs(info => ((RouteFuncAsync)info[1]).Invoke((Context)info[0]) ); _sut.Use(middleware.Handle); await _sut.GetRuntime(_handlerFunc.Handle).Invoke(null); await middleware.Received().Handle(Arg.Any <Context>(), Arg.Any <RouteFuncAsync>()); }