Create mock ICacheEntry IMemoryCache Xunit

You can use the below code to create a mock of ICacheEntry for IMemoryCache mock set up in Xunit:

Mock<IMemoryCache> mockObject = new Mock<IMemoryCache>();            
var cachEntry = new Mock<ICacheEntry>();
mockObject.Setup(x => x.CreateEntry(It.IsAny<string>()))
           .Returns(cachEntry.Object);

Namespaces used:

using Microsoft.Extensions.Caching.Memory;
using Moq;