How to chain multiple "ValueOf"

May 19, 2011 at 10:45 AM

Hello,

i want to check a result object of a function, if its of the right type and if its properties are filled correctly.

Following code does not work, because the type information seems to get lost in "Prop1.Should()"

GetResult().Should().Be.InstanceOf<ResultObject>()
.And.ValueOf.Prop1.Should().Be.Null()
.And.ValueOf.Prop2.Should().Be.True();

My actual workaround is to use LINQ via "Satisfy()", but is it possible to keep the fluent style?
Coordinator
May 21, 2011 at 4:45 PM

I prefer to use a line per each value... the test looks more clear to understand.

Jan 22, 2013 at 7:45 AM

I've had a similar problem, but mu "solution" is to do the following:

var isResultObject = GetResult().Should().Be.InstanceOf<ResultObject>();
isResultObject.And.ValueOf.Prop1.Should().Be.Null();
isResultObject.And.ValueOf.Prop2.Should().Be.True();
I don't really like have the same assertion multiple times, so this way, I'm asserting one property at a time.