What to unit test?
Some times it feels why the heck are we adding this unit test? Some times did we really added at least minimum required unit tests or not?
I spent good amount of time researching this topic.
My thumb rule is :
Assume you are adding a document with samples directly taken from Unit tests (except Mocking part though) ; We want our Unit tests to test what customer typically do.
Unit Test is a shield:
Unit test works like a shield. It protects from the minute it is born. This unit test shield will protect the code from your future self. This unit test shield will also protect from others working on this piece of code. Mistakes which will break some existing user can be avoided with this unit testing strategy.
Mock Vs Fake(Stub/Shim)
Use whatever works! External DLLs are better faked. But there are some beasts which will have give tough fight to be faked. In that case do not directly call this external DLL, rather call via a thin layer, a layer with zero business logic but with an interface+class design. Then mock this layer instead of trying to fake your external DLL. Unit tests are saved!