System.NotSupportedException: Invalid setup on a non-virtual (overridable in VB) member

前端 未结 2 366
清酒与你
清酒与你 2021-01-07 04:49

I am getting a NotSupportedException error message on my Unit Test using Moq

System.NotSupportedException: Invalid setup on a non-virtual (overridable

2条回答
  •  抹茶落季
    2021-01-07 05:33

    The property or function you're trying to setup needs to be declared as

    public virtual
    

    otherwise Moq can't create an inherited class, which overrides this function or propterty, which is nessecary, when you want to setup it.

提交回复
热议问题