Proper way of testing ASP.NET Core IMemoryCache
问题 I'm writing a simple test case that tests that my controller calls the cache before calling my service. I'm using xUnit and Moq for the task. I'm facing an issue because GetOrCreateAsync<T> is an extension method, and those can't be mocked by the framework. I relied on internal details to figure out I can mock TryGetValue instead and get away with my test (see https://github.com/aspnet/Caching/blob/c432e5827e4505c05ac7ad8ef1e3bc6bf784520b/src/Microsoft.Extensions.Caching.Abstractions