I have been reading about unit tests & Clean architecture and tried to implement something that would involve those two things.
It is my understanding that a Clean architecture is structured so that the methods of the Interactor object can be unit-tested.
But when the use case is something like "Create a file which content is computed from some data in some format", I get confused because it's not unitary (there's the computation of the file content, and the creation of the file, which are both in the use case)
Here's some pseudo-code illustrating my situation :
/* We are in an Interactor (i.e. UseCaseObject)
* This method 1)computes fileContent and 2)writes it into a file.
*/
public void CreateFileFromData(someDataInSomeFormat) {
var parsedData = SomeParser.Parse(someDataInSomeFormat);
string fileContent = ???;
WriteFile(fileContent);
}
My questions are the following :
- Must a method defined in the Interactor be unitary ? (as in, do only one thing)
- Must a method defined in the Interactor be unit-tested ? (I see a function, unitary or not, as a testable unit, please correct me if this is incorrect)
- Which class must hold the computation of fileContent in a Clean architecture ?