Created
March 6, 2011 01:51
-
-
Save joshka/856939 to your computer and use it in GitHub Desktop.
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
public static class ClassToBeTested | |
{ | |
public static void DoSomething(int input, AnotherCrazyPublicStaticClass staticClass) | |
{ | |
var result = staticClass.MethodToBeMocked(input); // go hit the database, network, web services, file and everything else you can imagine. | |
// now some business logic that I want to test | |
// 400 lines of code | |
// if result is blah do x otherwise do y | |
// 20 foreach loops each one with 2 nested loops and 10 if conditions. | |
} | |
} | |
// note class is no longer static | |
public class AnotherCrazyPublicStaticClass | |
{ | |
// instance method replacing previous static MethodToBeMocked() | |
public virtual int MethodToBeMocked(int input) | |
{ | |
// go hit the database, network, web services, file and everything else you can imagine. | |
return 0; | |
} | |
} | |
public class MockCrazy : AnotherCrazyPublicStaticClass | |
{ | |
public override int MethodToBeMocked(int input) | |
{ | |
return 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment