I have a method in the class for which they represent several different results (based on responses to events, etc.). But this is the only atomic function that is used by other applications.
I have broken down the basic blocks of functionality that include this function in different functions, and have successfully applied a testing approach to the functionality of each of these elements. However, these elements will not be used for other applications.
And so my question is, how can / easily approach the TDD style solution to verify that the only method that needs to be called works correctly without a lot of duplication in testing or the many settings needed for each test?
I examined / looked at moving blocks of functionality to another class and used Mocking to simulate the answers of the functions used, but it doesn’t feel good and individual methods should write variables in the main class (it really felt like heins robinson).
The code roughly looks like this (I removed a lot of parameters to make everything clearer, as well as a fair bit of irrelevant code).
public void MethodToTest(string parameter) { IResponse x = null; if (function1(parameter)) { if (!function2(parameter,out x)) { function3(parameter, out x); } }
jamie source share