private static void Main(string[] args) { // this entire example is based on a real-world example. i've // opted to try and introduce some complexity to the system by // creating some artificial dependency on an object reference. // throughout the code, you'll see that many of the classes depend // on having this set, although we never really do anything with // it. this is to simulate something closer to production code // where you may actually have additional dependencies passed down // your call/class hierarchy that you need to worry about. Console.WriteLine("Creating our super important dependency..."); var superImportantReference = new object(); // let's create an instance of our pre-refactor factory and an // instance of our factory after the lambda refactor. Console.WriteLine("Creating our pre/post refactor factory instances..."); var preRefactorFactory = new PreRefactorFactory(); var postRefactorFactory = new PostRefactorFactory(); // run all of the tests! (i opted to not include any real test // framework, but the concepts still apply) Console.WriteLine("Running 'GreaterThan' processor tests..."); TestGreaterThan(preRefactorFactory, superImportantReference); TestGreaterThan(postRefactorFactory, superImportantReference); Console.WriteLine("Running 'StringEquals' processor tests..."); TestStringEqual(preRefactorFactory, superImportantReference); TestStringEqual(postRefactorFactory, superImportantReference); /* * Exercise for you: implement the other processors in the pre- * refactor code and in the post refactor code. which method * involved more work? */ //TestLessThan(preRefactorFactory, superImportantReference); //TestLessThan(postRefactorFactory, superImportantReference); /* * Code some of the remaining test functions to see if your * implementations match up! */ Console.WriteLine("Press 'enter' to exit."); Console.ReadLine(); }