I'm currently debugging a very large public method that does these things.
- Fetch record(s) from DB
- Do some logical checks
- based on logical checks, determine if additional DB operations are done like save/ update/ delete
- Call a service and start a scheduled service
- etc, etc
Now, within these logical groups, it fetches data, etc, etc. Our architect has advised to write unit tests against it. If i break them down into smaller public methods that are being called from the big parent method, i know that it wont be good practice. Ive done some research and people said about saying something about using internal then exposing the assembly using InternalsVisibleTo. The method has also been existing for quite some time now and i want to avoid totally refactoring it and do really mind blowing regression testing.
Can anyone give me advice?
update
public JobModel SaveAndUpdateJob(JobModel jobModel)
{
using (var dbSession = OpenSession())
{
var jobEntity = isNew ? new JobEntity() : dbSession.Get<JobEntity>(jobModel.Id);
jobEntity.JobUniqueCode = jobEntity.GenerateUniqueCode(jobEntity, IsPublished);
RateJobAgainstSurvey(jobModel, dbSession, jobEntity);
_emailService.SendNotification(dbSession);
}
return jobModel;
}