5/16/2018»»Wednesday

Invalid Setup On A Non-virtual Overridable In Vb Member

5/16/2018
    86 - Comments
Moq Invalid Setup On A Non-virtual Member

Try using either of these: mockModel.Setup(m =>m. Apple Built-in Isight on this page. Items).Returns(listItem); mockModel.SetupGet(m =>m.Items).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. 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.

See More On Stackoverflow

Why does the property I want to mock need to be virtual? Invalid setup on a non-virtual (overridable in VB) member. Invalid setup on non-virtual member. Invalid setup on a non-virtual (overridable in VB) member: _ =>_.IsFoo(It.IsAny ()) あらら。エラーになってしまいました。. Invalid setup on a non-virtual (overridable in VB) member: _ =>_.IsFoo(It.IsAny ()) あらら。エラーになってしまいました。.