I am unable to insert a cache entry in ObjectCache with Set in my unit tests.
var objectCache = Substitute.For<ObjectCache>();
objectCache.Set("TestKey", object, Arg.Any<DateTimeOffset>());
When I step into my code
var cachedData = _objectCache.Get("TestKey");
// cachedData is null
I am using Nsubstitute for mocking libraries.
Does anyone know how to overcome this issue?
You will need to configure the mock for the
Getmethod. See the example for thereturnmethod in the NSubstitute docs.Something like...