Last active
June 2, 2024 15:15
-
-
Save craigeddy/fc2b8c6713ccb4b0d016ecfc7044c09b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mockConfiguration = new Mock<IConfiguration>(); | |
// Set up the GetSection method to return a Mock<IConfigurationSection> | |
mockConfiguration.Setup(config => config.GetSection(It.IsAny<string>())) | |
.Returns(new Mock<IConfigurationSection>().Object); // returns a new Mock IConfigurationSection object | |
// Set up the Value property of the IConfigurationSection to return a specific value | |
mockConfiguration.Setup(config => config[It.IsAny<string>()]) | |
.Returns("YourValue"); // returns "YourValue" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment