Replies: 2 comments
-
Hi @edmd , I'm taking a look at this, will let you know. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Can you give me more context on the error you're getting so I can deep dive better? Out of curiosity, cause maybe it can be useful here, do you already know about the null implementations provided in the package? I'm talking about the classes in the Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there,
Hoping for some assistance with the below. I am trying to Moq my call to the GetOrSetAsync API. The actual code looks like so:
cachedItem = await _distributedCache.GetOrSetAsync( eventRequest.Policy.CacheKey, async _ => (await _service.GetPolicy(eventRequest))?.FirstOrDefault(), new FusionCacheEntryOptions { Duration = TimeSpan.FromSeconds(eventRequest.Policy.TimeToLiveInSeconds) }, cancellationToken );
Can I confirm that the Moq Setup signature would look like the following:
_distributedCacheMock .Setup(dc => dc.GetOrSetAsync( policy.CacheKey, It.IsAny<Func<FusionCacheEntryOptions, Task<Policy.Models.Policy?>>>(), It.IsAny<FusionCacheEntryOptions>(), It.IsAny<CancellationToken>())) .Returns(new ValueTask<Func<FusionCacheEntryOptions, Task<Policy.Models.Policy?>>>( options => Task.FromResult(policy)! ));
When I run the test, it's not hitting my Moq'ed Setup and I don't know how to fix this...
I assumed that something like the following might work:
_distributedCacheMock .Setup(dc => dc.GetOrSetAsync( policy.CacheKey, It.IsAny<Func<FusionCacheEntryOptions, Task<Policy.Models.Policy?>>>(), It.IsAny<FusionCacheEntryOptions>(), It.IsAny<CancellationToken>())) .ReturnsAsync(policy);
or:
.Returns(Task.FromResult(policy));
But neither of these options compile.
What is the Moq Setup supposed to look like, I was looking for something in the docs.
Beta Was this translation helpful? Give feedback.
All reactions