← ClaudeAtlas

csharp-testinglisted

Unit-test code that calls the PayPal Server SDK C# SDK. Load before stubbing the SDK. The member list won't tell you the one injectable seam is an `HttpMessageHandler` passed through `.HttpClientConfig(...)`, that the client is `sealed` with an internal controller constructor, or the two things a stub handler must do before a call gets through at all.
MuHamza30/paypal-api-plugin · ★ 0 · Testing & QA · score 70
Install: claude install-skill MuHamza30/paypal-api-plugin
# Testing code that uses an APIMatic C# SDK The SDK ships **no mocking helpers and no in-memory transport**. The one injectable seam is the `HttpClient` it calls through — `.HttpClientConfig(config => config.HttpClientInstance(new HttpClient(handler)))`, with an `HttpMessageHandler` you write. Confirm both members first: `HttpClientConfig(Action<HttpClientConfiguration.Builder>)` in `PaypalServerSdkClient.cs` and `HttpClientInstance(HttpClient, bool overrideHttpClientConfiguration = true)` in `Http/Client/HttpClientConfiguration.cs`. The samples below use xUnit for reference only — mirror whatever the project already uses. ## What you cannot fake — and what to do instead **This SDK emits no interfaces, so there is nothing for a mocking library to substitute.** The client is `sealed` with a `private` constructor, its only interface exposes configuration but no operations, and every operation is a plain **non-`virtual`** method behind an `internal` constructor. So put a narrow interface of your own in front of the SDK, implement it over the client — calling `_client.{Controller}.{operation}Async(id, cancellationToken: ct)` and returning whatever your callers need — and test *that* against the stub handler below. See **csharp-client-initialization**. Faking the SDK's own types is cheap — they all have public constructors: `ApiResponse<T>` (`public ApiResponse(int, Dictionary<string, string>, T)`), every model, and every typed exception (`public {Error}Exception(string reas