I am using RhinoMock in VB.NET and I need to set the return value for a read-only list.
Here is what I want to do (but not working):
dim s = Rhino.Mocks.MockRepository.GenerateStub(of IUserDto)()
s.Id = guid.NewGuid
s.Name = "Stubbed name"
s.Posts = new List(of IPost)
Compilation fails because Posts is a readonly property.
Then I tried a lambda expression that works great for function calls, but not so much for properties. This does not compile.
s.Stub(Function(x As IUserDto) x.Posts).Return(New List(Of IPost))
The next attempt (unsuccessful attempt) was to use SetupResults, but this did not confirm that it cannot be used in playback mode.
Rhino.Mocks.SetupResult.For(s.Posts).Return(New List(Of IPost))
Which brings me back to my question:
How to set return value for readonly property using RhinoMocks in VB.NET?