I am getting a NotSupportedException error message on my Unit Test using Moq
System.NotSupportedException: Invalid setup on a non-virtual (overridable
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.
Assuming you're using EF of at least V6 and based on this example (look at the Blogs element) which is doing a very similar thing to you. I'd guess that your problem is that your dataAccess
, whatever it is doesn't declare Stocks
as virtual.
So it should look something like this:
public virtual DbSet<Stock> Stocks { get; set; }