4. What's a Unit? Unit == class || method Unit != classes.Count > 1
5. How to test? Manually? –possible, but not so friendly Automated Frameworks: NUnit MSTest MbUnit etc.
6. Testing Framework A set of code and tools to test existing code Testing code is decorated with attributes Testing Framework uses Reflection to invoke testing code Most tests either Passor Fail
7. Demo – Array Util The task: A method has 2 input parameters: A non empty, sorted array of integers An integer The output should be the closest number from the array to the input number. "Closest" in terms of absolute value Try to write it yourself!
8. Why Unit Testing? Unit Testing is a STANDARD No need to manually test code by console applications Accepted by Developers Expected by Developers Fearlessly Change Implementation
10. Why Unit Testing? Leads us to Better Code / Better Design Demo: Greet example
11. I Can't Test That Code More than a single class is used Even worse: Singletons are used Hardware boundaries: System Clock HTTP Requests File Read/Write Refactor!
12. Unit Testing More code to test our code Unit Testing Leads to: Fearlessly Change Implementation Better Code / Better Design If a class can't be tested – consider refactoring Legacy code is code without tests