I have a problem in my test case, I am trying to mock the return of my ICacheProvider
but it always returnsnull
.
[Fact]
public void Raise_ShoultReturnTrue_IfItsInCache()
{
var cacheProvider = Substitute.For<ICacheProvider>();
cacheProvider.Fetch(Arg.Any<string>(), default(Func<IEnumerable<int>>)).ReturnsForAnyArgs(GetFakeCacheDB());
//I was expecting the var below to contain the data from GetFakeCacheDB method
var cacheProviderReturn = cacheProvider.Fetch("anything", returnEmpty);
//there is more stuff here but doesnt matter for the question
}
private HashSet<int> returnEmpty()
{
return new HashSet<int>();
}
private IEnumerable<int> GetFakeCacheDB()
{
var cacheData = new List<int>()
{
57352,
38752
};
return cacheData;
}
public interface ICacheProvider
{
void Add<T>(string key, T item);
void Add<T>(string key, T item, DateTime? absoluteExpiry, TimeSpan? relativeExpiry);
T Fetch<T>(string key, Func<T> dataLookup);
T Fetch<T>(string key, Func<T> dataLookup, DateTime? absoluteExpiry, TimeSpan? relativeExpiry);
void Remove<T>(string key);
}
What is wrong in my test case?