Join Reynald Adolphe for an in-depth discussion in this video Unit testing constructors, part of C# Best Practices for Developers.
- [Instructor] So we're ready to create our test…and I will go ahead and create a test called…Test Parameterized Constructor.…I'll start off by my annotation.…Public void…Test Parameterized…Constructor.…
And of course, we'll be doing some arranging,…acting and asserting.…We'll start off by defining a current actor…and creating an instance…of actor where we pass into the name, Johnny Boy.…
Then our expected value…is Johnny Boy.…To get that value, we want the result…to come from whatever's in the property name,…ActorName.…At this point, we can assert…to see if, indeed, our expected is equal to the result.…
Now, I'll go ahead and save.…To run the test, I'll go ahead and set a break point here.…In our Test Explorer,…I'll right click on TestParameterizedConstructor,…and choose Debug Selected Test.…Now when I step through and get on line 30,…I can compare whether the expected,…which is Johnny Boy,…is equal to result, which is Johnny Boy.…
Perfect, so now when I hit Continue,…our test should pass.…And it does.…Now, if I didn't want to debug,…
- Naming and handling classes
- Running a unit test
- Using constructors
- Naming and handling methods, fields, and properties
- Using properties correctly
- Managing objects efficiently
- Common design patterns as best practices
Skill Level Intermediate
1. Best Practices: An Overview
2. Naming and Handling Classes
3. Naming and Handling Methods, Fields, and Properties
4. Managing Objects Efficiently
5. More Best Practices Resources
- 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.