Join Bruce Van Horn for an in-depth discussion in this video Writing a unit test, part of C# Essential Training: 2 Flow Control, Arrays, and Exception Handling.
- [Instructor] Now that we've got our testing project set up…let's go ahead and write our very first test.…You no doubt noticed when we created this project…that Visual Studio generated…some files for us automatically.…We have Class1.cs here in the EssentialTraining Project…and the EssentialTrainingTests Project, we have UnitTest1.…The first thing I like to write some trivial test…in my projects to make sure everything is working correctly.…So for that, why don't we just use these two files…that were generated for us automatically.…
I'll go ahead and open up Class1.cs…by double clicking it in the Solution Explorer.…And inside Class1, I'll make some really trivial method.…In this case, I'll just add two numbers together.…So I'll type in public int AddTwo…and I'll add my two integers together, int a and int b.…And for my return statement,…I'll just type in return a plus b.…Make sure you save.…And now let's write a unit test for this.…
To do this, I need to switch over to the unit test file.…Now I have it up here in the tab,…
AuthorBruce Van Horn
- Writing unit tests in C#
- Working with simple and multidimensional arrays
- Managing ordered and unordered data with lists
- Evaluating conditions with if-else statements
- Using OR, AND, and NOT operators
- Building loops
- Debugging and handling exceptions
- Creating the final build of your C# project
Skill Level Beginner
C# Object-Oriented Programming Tips and Trickswith Jesse Freeman58m 39s Intermediate
1. Unit Testing and Test-Driven Development
2. Arrays and Collections
3. Flow Control
4. Exception Handling
5. Getting to Production
Next steps1m 57s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.