I'm refactoring legacy code to make it (unit) testable. I have two classes implementing the same interface, as shown below. In one of the classes I have an external dependency towards DirectoryEntry. My suggested way of dealing with that is to create an IDirectoryEntry interface, and pass the directory entry as a parameter to the GetGroups method. The problem is that that would break IMyInterface.
What would a better way to refactor this code?
public interface IMyInterface
{
List<string> GetGroups();
}
public class MyFirstClass : IMyInterface
{
public List<string> GetGroups()
{
..
var directoryEntry = new DirectoryEntry(path);
..
return something;
}
}
public class MySecondClass : IMyInterface
{
public List<string> GetGroups()
{
return somethingElse;
}
}
Regards, Frank
Aucun commentaire:
Enregistrer un commentaire