Instantly share code, notes, and snippets.

Embed
What would you like to do?
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