Skip to content

Instantly share code, notes, and snippets.

@CopperStarSystems
Last active September 27, 2016 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CopperStarSystems/5072216d66fcd1ce10521bb5a0ad2005 to your computer and use it in GitHub Desktop.
Save CopperStarSystems/5072216d66fcd1ce10521bb5a0ad2005 to your computer and use it in GitHub Desktop.
Example of a C# class with untestable dependencies
// This is an example class illustrating some common patterns
// that negatively impact testability
public class ReallyHardToTest{
SomeModel model;
public ReallyHardToTest(SomeOtherDependency otherDependency){
model = new SomeModel();
otherDependency.DoSomething();
}
public void SetFilename(string fileName){
model.Filename = Path.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