have "Googled the cr*p" out of this one so apologies if the answer is either on here, or fairly simple.
I am writing Unit tests. In this particular one I am instantiating an object using a parameterless constructor. When instantiating using that constructor none of its properties will be set.
I then, as part of the test, want to "loop" through the properties and assert that they are either "null", "0" or "false" (which would be the correct state).
I know it sounds like a dumb thing to do, but if I can do this, then I can write more efficient and readable tests for everything else.
I know I can "loop" through the properties of a "Type", but that's not an instantiated object "of type". It's a "Type" object.
In my head it should be (but obviously isn't) the following:
var target = new MyObject();
foreach(var property in target.GetProperties())
{
Assert.IsNull(property);
}
Anyone?