The Humble Object Pattern #100
Replies: 1 comment 3 replies
-
|
Here's another tip that I love. Create a delegate and add it to dependency injection with a lambda expression as the implementation. For example: Now any classes that need to generate a Guid can accept the delegate as a dependency. Then when you write your unit test, it's super easy to mock and your test will be deterministic because you can control the exact Guid value. Do this for Dates or Random, too, or anyhing that can prevent your test from being deterministic |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The Humble Object Pattern
The Humble Object Pattern is a design pattern to make especially unit testing easier with the goal of separating behaviors that are easy to handle (domain logic) from behaviors that are hard to handle (like external events or dependencies).
So let's have a look at what it is and how you can utilize it.
https://steven-giesel.com/blogPost/47acad0a-255c-489b-a805-d0f46bde23e5/the-humble-object-pattern
Beta Was this translation helpful? Give feedback.
All reactions