You must check the properties. Also automatic properties!
Unittests assure that changes in the program do not interfere with the program.
You can end up changing the implementation of the property at some time, and you want to make sure that the program is still working properly. You do this with your tests.
Even if you use automatic properties (as a replacement for fields / member variables), the reason for creating them is that you will want to subsequently change their implementation. Then you want the tests to be there.
EDIT: (In response to the comment on shahkalpesh ...)
If you change implementations, tests may also require changes. So, I do not know why someone should test the simple ones to get / install?
Starting from this class:
public class TimeOfDay { public int Hour{get; private set;} public int Minute{get; private set;} public TimeOfDay(int hour, int minute) { Hour = hour; Minute = minute; } }
When the implementation changes, the tests remain valid!
public class TimeOfDay { public int _minutesSinceMidnight = 0; public int Hour { get { return _minutesSinceMidnight / 60; } set { _minutesSinceMidnight = value * 60 + Minutes; } } public int Minute { get { return _minutesSinceMidnight % 60; } set { _minutesSinceMidnight = Hour * 60 + value; } } public TimeOfDay(int hour, int minute) { Hour = hour; Minute = minute; } }
Throw some arithmetic functions of time and time or something else, and I would like the tests to show that it still works ...
source share