Skip to content

Conversation

@f-regal
Copy link

@f-regal f-regal commented Oct 14, 2025

Description

  • Refactor payment logic to decouple storage from business rules by introducing IAccountDataStore and IAccountDataStoreFactory and a default AccountDataStoreFactory.
  • Make PaymentService depend on the factory (constructor injection) while preserving the MakePayment method signature and backwards compatibility via a default constructor.
  • Implement existing concrete stores to satisfy the new interface.
  • Add unit test project dependencies (xUnit, Microsoft.NET.Test.Sdk, test runner) and CopyLocalLockFileAssemblies to ensure runtime dependencies are available for testhost.
  • Add unit tests (PaymentServiceTests) exercising BACS, FasterPayments and CHAPS rules; include an ExampleTests sample.
  • Small build/test/runtime fixes to avoid testhost deps issues encountered earlier.

What changed (files)

  • Modified
    • PaymentService.cs
    • AccountDataStore.cs
    • BackupAccountDataStore.cs
    • ClearBank.DeveloperTest.Tests.csproj
  • Added
    • IAccountDataStore.cs
    • IAccountDataStoreFactory.cs
    • AccountDataStoreFactory.cs
    • PaymentServiceTests.cs

Motivation / rationale

  • Improve adherence to SOLID (Single Responsibility, Dependency Inversion) and make payment logic easily unit-testable without hitting a real datastore.
  • Preserve original public API (MakePayment signature) as required.
  • Fix test runtime failures caused by missing transitive runtime assemblies in test output by ensuring test SDK and CopyLocalLockFileAssemblies are configured.

Behavioral notes and compatibility

  • Business logic behavior is preserved; existing callers of new PaymentService() continue to work with default factory that reads configuration.
  • Tests are pure unit tests using fakes, no external I/O.

How to run and verify

  • Ensure .NET 8 SDK installed.
  • From repo root:
dotnet restore
dotnet build
dotnet test
  • Expected: build succeeds and tests run (unit tests pass).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant