Student will create a more complex project solution for unit testing. The purpose of the program is thouroughly explained to student so they have a strong foundation draw ideas for potential test cases. The program will be a salary calculator that will determine the weekly salary of an employee and print out a statement idicating it. The program will do the same for contracts but include overtime.
- [Voiceover] Now, even though it's the ideal scenario…with test-driven development to write test cases…first, that drive the design of your program,…there's probably going to be times you'll begin…with an existing solution…that you need to write test cases for.…In this scenario, that's what we're gonna do…to get a sense of that process.…So let's start by opening up the solution…called "polymorphism" from the start folder…of chapter four in exercise one.…You'll see a program file in the project.…
If you'll double-click that, you'll see some of the code…that we're gonna ahead and examine.…This program is a bit more advanced…compared to the last one we did because it's polymorphic.…It's gonna print two line.…One indicating a week's pay for an employee…and the other, a week's pay for a contractor.…The only difference is that the contractor…gets paid overtime.…But before we dive too much into the code,…let's go ahead and and run the program…to see the lines that I'm talking about.…
By hitting control + F5…to run the console and pause it.…
In this course, Reynald Adolphe explains the principles of test-driven development and shows how to apply them to two different C# workflows. First, he creates a new test-driven project. He writes the test cases before the code to drive the design of the program. In the second scenario, he writes test cases for an existing C# project, to find bugs before it goes live. Along the way, Reynald uses Microsoft's MSTest, but he also introduces other testing tools (such as the unit testing framework xUnit and the mocking framework Moq) and theories (such as the red-green-refactor mantra and SOLID principles) that make test-driven development so efficient.
- Different approaches to testing
- Using testing tools and mocking frameworks
- Creating a simple C# test-driven project
- Adding a failing test
- Updating tests to pass
- Refactoring code
- Using Moq to test data