Skip to content

test: Unit & integration tests for SquadGateway #43

Description

@teesofttech

Overview

Add a complete unit and integration test suite for SquadGateway.

Gateway Details

Unit Tests (mocked HTTP)

Constructor

  • Throws InvalidOperationException when SecretKey is null/empty
  • Uses SandboxUrl when IsSandbox=true
  • Uses LiveUrl when IsSandbox=false

CreatePaymentAsync

  • Posts to /transaction/initiate with correct payload (amount in kobo, email, currency=NGN, initiate_type=inline)
  • Sets Authorization: Bearer header
  • Returns PaymentResponse.Success=true with CheckoutUrl (checkout_url) on success
  • Returns PaymentResponse.Success=false on API failure

VerifyPaymentAsync

  • Sends GET /transaction/verify/{reference}
  • Returns IsSuccessful=true when transaction_status=success
  • Returns IsSuccessful=false for failed/pending

RefundPaymentAsync

  • Posts to /transaction/refund with correct payload
  • Returns RefundResponse.IsSuccessful=true on success

Integration Tests

Requires SQUAD_SECRET_KEY env var and SQUAD_IS_SANDBOX=true

  • CreatePaymentAsync returns a real Squad checkout URL
  • VerifyPaymentAsync returns correct status

Files to Create

  • PayBridge.SDK.Test/Unit/SquadGatewayTests.cs
  • PayBridge.SDK.Test/Integration/SquadIntegrationTests.cs

Acceptance Criteria

  • All unit tests pass with zero live HTTP calls
  • Integration tests use [Trait("Category", "Integration")] and skip when env vars are absent
  • Code coverage >= 80% for SquadGateway.cs

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: gatewaysPayment gateway integrations and provider behaviorarea: testingAutomated test architecture and coveragepriority: P1High priority; should be addressed nexttestingTest coverage and test suite work

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions