How to mock IConfiguration

var configuration = new Mock<IConfiguration>();
 
var configurationSection = new Mock<IConfigurationSection>();
configurationSection.Setup(a => a.Value).Returns("testvalue");
 
configuration.Setup(a => a.GetSection("TestValueKey")).Returns(configurationSection.Object);   

Source