I have a method that takes 5 parameters. This method is used to collect the collected information and send it to my server.
I am writing unit test for this method, but I got a little hooked. Some of the parameters are lists of <> classes that require some tweaking for proper tweaking. I have methods that correctly set them in other units (production code units). But if I name them, then I kind of break up the whole idea of unit test (only for one "unit").
So ... what should I do? Am I duplicating the code that installs these objects in my test project (in a helper method), or am I starting to call production code to configure these objects?
Here is a hypothetical example to try to make this clearer:
File: UserDemographics.cs
class UserDemographics
{
}
File: UserGroups.cs
class UserGroups
{
public AddUserDemographicsToGroup(UserDemographcis userDemographics)
{}
}
File: UserSetupEvent.cs
class UserSetupEvent
{
public SetupUserEvent(List<UserDemographics> userDemographics,
List<UserGroup> userGroups)
{}
}
file: Communications.cs
class Communications
{
public SendUserInfoToServer(SendingEvent sendingEvent,
List<UserDemographics> userDemographics,
List<UserGroup> userGroups,
List<UserSetupEvent> userSetupEvents)
{}
}
So, the question is that: unit test SendUserInfoToServerdo I need to duplicate SetupUserEventand AddUserDemographicsToGroupin my test project, or do I just need to call them to help me set up some "real" parameters?
source
share