-
-
Notifications
You must be signed in to change notification settings - Fork 835
Getting errors when attempting to setup a method with an out parameter #436
Copy link
Copy link
Closed
Labels
Description
I am having a very difficult time attempting to mock the ASP.Net Core IMemoryCache object. I have the mock set up as follows:
var memoryCacheMoq = new Mock<IMemoryCache>();
Lookup dummy = new Lookup { };
memoryCacheMoq.Setup(m => m.TryGetValue(It.IsAny<object>(), out dummy)).Returns(false);
I want the method to return false so my database mock performs what it's supposed to do.
When I debug this, I get the following error when it gets to the setup line:
Message: System.NotSupportedException : Invalid setup on an extension method:
m => m.TryGetValue<Lookup>(It.IsAny<Object>(), .dummy)
From everything I've read, and even watched an example on PluralSight, this is the way to set this up.
Any assistance is greatly appreciated! Thank you.
Reactions are currently unavailable