Often times, a class does not have direct output; It manages its dependency, so that they work.
For example:
Internal interface IEmailer {Zero SendEmail (); } Class Reports Sender {Public Email Mailer Emailer {Received; Set; } Public Report Sender (IEmailer emailerToUse) {Emailer = emailerToUse; } Public Zero SendReport () {// Whatever the Report is required to create the Emailer SendEmail (); }} Fake the IEmailer and expect it to be EEmailer. SendEmail () It seems that exposing too many homes in the classroom and making the test delicate. But I can not think of this class in any other way.
How do we write unit tests for this kind of class?
Due to the EEmailer imitation, the class is not exposed too much; instead, it extensibilty Creates Open for
There is a certain motivation that depends on interconnected test (i.e. mocks) makes tests more delicate
Theory of Hollywood can be really useful, because if your dependency is mostly prepared around zero methods, mike or rhino mokes like dynamic mock will usually ignore the call, unless You are particularly concerned about a particular special Do not do.
Comments
Post a Comment