Trap vs. Test Data

I am not doing many new developments right now, but many refactoring older C # subsystems whose initial requirements no longer support the new ones, and I will add unexpected requirements. I also now use Rhino Mocks and unit tests where possible (vs 2008).

The dilemma for me is that in order for methods to be tested and mocked up, I need to define clear “contracts” using interfaces. However, if I do this, many global data that many of the classes use is converted to tramp data, passed from method to method until it reaches its intended user; it looks ugly and contrary to my sensitivity, but ... you can make fun of it. Creating a mixed bag class with many static global properties is a more attractive option, but not an innovative test. Between them two means? Test, but not too tram? Perhaps a pattern?

You should also understand that these applications work on their own corporate platform, so there are many helper classes and services that are created once for each application, and then used throughout the application, for example, to access the database helper class. Another example is the use of configuration files that are read once and are used throughout the application in various ways for various reasons.

Your thoughts are appreciated.

+3
source share
1 answer

What you can see here is some form of service locator pattern . Make their classes find their own vagrants.

" ".

, .

+3

Source: https://habr.com/ru/post/1760181/


All Articles