public void Setup() { var requests = this.requestFactory.TakeRequestTypes(RegistratedRequestsCount).ToList(); var requestToProcess = requests[RegistratedRequestsCount / 2]; this.requestName = requestToProcess.Name; var runner = new RpcRequestRunner( // As MediatR-RPC only use the non-generic MediatR api, we can just return any type. // Doesn't have to match the corresponding in request and it will not effect the benchmarking. new FakeSender(new RpcBenchmarkResponse()), new RpcOptions() .UseExactRequestTypeNameMatchingConvention() .ScanRequests(requests)); this.middleware = new RpcMiddleware( new RequestDelegate(c => Task.CompletedTask), new RpcEndpointOptions { Path = "api" } .UseSystemJsonForDeserializeBody() .UseSystemJsonForOkOrNotFoundResult(), new FakeRpcRequestRunner()); this.httpContext = new FakeHttpContext(); this.httpContext.Request.RouteValues.Add(RequestName, string.Empty); this.httpContext.Request.Body = CreateStreamFromType(requestToProcess, out var contentLength); this.httpContext.Request.ContentLength = contentLength; }
public void Setup() { this.middleware = new RpcMiddleware( new RequestDelegate(c => Task.CompletedTask), new RpcEndpointOptions { Path = "api", DeserializeRequest = (r, ct) => Task.FromResult(new object()), SerializeResponse = (r, ct) => Task.CompletedTask }, new FakeRpcRequestRunner()); this.httpContext = new FakeHttpContext(); this.httpContext.Request.RouteValues.Add(RequestName, string.Empty); }