From the course: C# Best Practices for Developers
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Auto-implemented properties demo - C# Tutorial
From the course: C# Best Practices for Developers
Auto-implemented properties demo
- [Instructor] Okay, so we're ready to create our test methods. Let's go onto our ActorTest file. And I will go ahead and just copy and paste our last TestMethod and modify this for our specific purpose right now. I'll give it the name of TestAutoProp, short for property, ActorDescription. And let's clear out what we have in Act and Arrange. And we'll go ahead and create the method stub for our next test, which will test AutoPropInit, for the initializer, ActorAge. We'll comment this out for now. For our first test, we'll create our currentActor. That is going to be a new instance of an Actor. And we'll be initializing the ActorName as Sandy Love. Our expected value is she's going to be a regular actor. That's our description. And for the result, we will invoke ActorDescription. All right, moving on to our second test. We'll uncomment that. And here, I'll jump to line 83, copy what we have. And the only difference that I'm going to add, after I paste in, is specify her age. Which…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Method overloading5m 16s
-
(Locked)
Unit testing without parameters4m 5s
-
(Locked)
Unit testing with parameters2m 54s
-
(Locked)
Method chaining4m 7s
-
(Locked)
Constants vs. read-only fields5m 28s
-
(Locked)
Using properties correctly2m 11s
-
(Locked)
Using properties demo4m 29s
-
(Locked)
Auto-implemented properties1m 33s
-
(Locked)
Auto-implemented properties demo5m 13s
-
(Locked)
-
-
-