Student will create a simple project solution for unit testing. Student will be explained the pupose of the progam about be created which involves accepting an annual salary to determing the hourly wage of an employee. The second function student will write will accept an hourly wage and calculate the annual salary. Student is then introduced to the default TestMethod stub which they will modify & use to implement the Arrange/Act/Assert process in the upcoming videos.
- [Voiceover] All right, let's go ahead…and create our first program.…It's going to be a simple annual salary…and hourly wage calculator.…And it's going to have two functions.…One will be to determine your hourly wage…by dividing your annual salary by 2080.…And the other function will be to determine your annual…salary by multiplying your hourly wage by 2080.…Now because we're doing this through test driven…development and how it's intended we're going…to be creating the unit test first and that will draw…the design of our program.…
So let's go ahead and launch Visual Studio…and start by creating a new project.…Under Templates Visual C# we'll select on Test…and then type in a project name…SalaryCalculatorTestProject.…And click Ok.…And as you see Visual Studio created a default test class…named UnitTest1…and a test method called TestMethod1.…
Let's go ahead and paste in our requirements…and that's it.…Now keep in mind that because we're doing…test driven development there's the red green…refactor model that we follow.…
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