This repository contains examples of Contract Tests in various programming languages.
This example is loosely based on the TradeOrderRepository found in the "Domain-Driven Design: Tackling Complexity in the Heart of Software"
book by Eric Evans.
Implement the TradeOrderRepository with a database storage. The repository should have two methods:
-
forTrackingId(String): TradeOrder- takes the tracking ID and returns a TradeOrder. -
outstandingForBrokerageAccountId(String): List<TradeOrder>- takes the brokerage account ID and returns a list of TradeOrders
The expected behaviour of TradeOrderRepository methods:
forTrackingId- returns the TradeOrder if it exists for the given tracking ID
- returns
nullif the TradeOrder is not found for the given tracking ID (alternatively, expect an exception)
outstandingForBrokerageAccountId- returns all outstanding TradeOrders for the given account ID
- returns an empty list if no TradeOrder was found for the given account ID
- Kotlin | Steps: Domain Model > Integration microtest > Extract SUT and fixture creation > Contract placeholder > Pull test methods up to the contract test > Second adapter
- Kotlin (composition) | Steps: Domain Model > Integration microtest > Extract SUT and fixture creation > Contract Test > Move the Contract Test > Second adapter