Easier way to setup properties on Data Transfer Objects?

2 views
Skip to first unread message

TrueWill

unread,
Oct 27, 2009, 1:34:26 PM10/27/09
to Moq Discussions
I have an interface that consists solely of properties. I want to
create a collection containing a number of instances of objects
implementing this interface. Is there an easy way to do it in Moq?

Basically I want to write the equivalent of the following as concisely
as possible, but using a mock (stub) rather than a concrete Foo. The
actual code has more than two properties.

.Returns(new Collection<IFoo>
{
new Foo
{
IsRequired = true,
ItemId = 1
},
new Foo
{
IsRequired = false,
ItemId = 2
}
}

If this isn't possible currently, it might be a nice feature to add.
It would be similar to SetupAllProperties. Thanks!
Reply all
Reply to author
Forward
0 new messages