-
-
Save CopperStarSystems/b2fa54276cb906560d04d9566a78b11a to your computer and use it in GitHub Desktop.
Integrating IPathWrapper into the ReallyHardToTest class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an example class illustrating some common patterns | |
// that negatively impact testability | |
// | |
// In this round, we have removed the static dependency on | |
// System.IO.Path | |
public class ReallyHardToTest{ | |
SomeModel model; | |
IPathWrapper pathWrapper; | |
public ReallyHardToTest(SomeOtherDependency otherDependency, IPathWrapper pathWrapper){ | |
this.pathWrapper = pathWrapper; | |
model = new SomeModel(); | |
otherDependency.DoSomething(); | |
} | |
public void SetFilename(string fileName){ | |
model.Filename = pathWrapper.GetFileName(fileName); | |
} | |
} | |
public class SomeModel{ | |
public string Filename{get;set;} | |
} | |
public class SomeOtherDependency{ | |
public void DoSomething(){ | |
// Just here for illustration | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment