public async Task GlobalErrorHandler() { await _host .ConfigureServices(services => { services.AddServiceModelGrpc(options => options.DefaultErrorHandlerFactory = _ => _globalErrorHandler); }) .ConfigureEndpoints(endpoints => { endpoints.MapGrpcService <ErrorService>(); }) .StartAsync(); _domainService = _host.ClientFactory.CreateClient <IErrorService>(_host.Channel); Assert.Throws <RpcException>(() => _domainService.ThrowApplicationException("some message")); _clientMetadata.Count.ShouldBe(1); _clientMetadata[0].Key.ShouldBe("GlobalErrorHandler", StringCompareShould.IgnoreCase); }
protected override void ConfigureKestrelHost(KestrelHost host) { host .ConfigureServices(services => services.AddTransient <IServiceWithAuthentication, ServiceWithAuthentication>()) .ConfigureEndpoints(endpoints => endpoints.MapGrpcService <IServiceWithAuthentication>()); }