Moq Linq-to-SQL readonly property

tommypop

New Member
I have a table \[code\]aspnet_User\[/code\] in my model(dbml file) where I have a property \[code\]UserName\[/code\] which is ReadOnly. I thought I could do this.\[code\]var mockAsp_NetUser = new Mock<aspnet_User>();mockAsp_NetUser.SetupGet(au => au.UserName).Returns("JohnDoe");\[/code\]But then I get an exception: Invalid setup on a non-overridable member.An easy solution would be to set the ReadOnly property for \[code\]UserName\[/code\] to false in the model designer. But this might be a hack. Is there a more "correct" way?
 
Back
Top