Overview
Before building per-gateway test files, establish the shared test infrastructure that all unit and integration tests will rely on.
What to Build
MockHttpMessageHandler
A reusable DelegatingHandler (or implementation of HttpMessageHandler) that:
TestFixtures
IntegrationTestBase
Test Category Traits
Directory Structure
PayBridge.SDK.Test/
Unit/
PaystackGatewayTests.cs
FlutterwaveGatewayTests.cs
... (one per gateway)
Integration/
PaystackIntegrationTests.cs
... (one per gateway)
Helpers/
MockHttpMessageHandler.cs
PaymentRequestFactory.cs
GatewayConfigFactory.cs
IntegrationTestBase.cs
PayBridgeTests.cs (existing smoke tests)
Acceptance Criteria
Overview
Before building per-gateway test files, establish the shared test infrastructure that all unit and integration tests will rely on.
What to Build
MockHttpMessageHandler
A reusable
DelegatingHandler(or implementation ofHttpMessageHandler) that:(method, url pattern, statusCode, responseBody)tuples to queue upInvalidOperationExceptionif an unexpected request is madeTestFixtures
PaymentRequestFactory.Build()— returns a validPaymentRequestwith sensible test defaultsRefundRequestFactory.Build()— returns a validRefundRequestGatewayConfigFactory.BuildPaystack(secretKey)— returns aPaymentGatewayConfigwith Paystack configured (one per gateway)IntegrationTestBase
Skip.IfNot()(orAssert.Skip()) when missing.env.testvia dotenv or directly from environmentTest Category Traits
[Trait("Category", "Unit")]on all unit test classes[Trait("Category", "Integration")]on all integration test classes.runsettingsto allow running only unit tests withdotnet test --filter Category=UnitDirectory Structure
Acceptance Criteria
dotnet test --filter Category=Unitruns only unit testsdotnet test --filter Category=Integrationruns only integration tests