Invalid Setup On A Non-virtual Overridable In Vb Member

Posted on by

Invalid setup on a non-virtual (overridable in VB). Invalid setup on a non-virtual (overridable in VB) member. I have a unit test where i have to mock a non. Moq cannot mock non-virtual methods and sealed classes. While running a test using mock object, MOQ actually creates an in-memory proxy type which inherits from your 'XmlCupboardAccess' and overrides the behaviors that you have set up in the 'SetUp' method. Why am I getting an Exception with the message 'Invalid setup on a non-virtual (overridable in VB) member.' Invalid setup on a non-overridable member? Showing 1-4 of 4 messages. Invalid setup on a non-overridable member? Champions Gold Membership Hack. Diogo Menezes: 7/14/10 8:10 PM.

Try using either of these: mockModel.Setup(m =>m.Items).Returns(listItem); mockModel.SetupGet(m =>m.Items). Zonet Pci Wireless Card Driver there. Returns(listItem); The method SetupProperty is used when you want to track its value, see. Although I am not enterily sure why SetupProperty fails, as its intention is to be able to assing and retrieve the property value, it seems likely to be caused by the private get. To be clear, let's assume your property has a public set.

Give More Feedback

In that case when using Setup or SetupGet, doing something like mockModel.Object.Items = new List(); would have no effect and you would still see the list with a single item. However with SetupProperty the same statement would have changed the value returned by the property. Basically SetupProperty allows to get AND SET the value of a property and that's why I think it cannot be used with a private set.