0

我有接口和类 ConfigurationReader:

public interface IConfigurationReader
{
  string GetAppSetting(string settingName);
}

public class ConfigurationReader : IConfigurationReader
{
  public string GetAppSetting(string settingName)
  {
    return ConfigurationManager.AppSettings[settingName];
  }
}

我正在尝试模拟 IConfigurationReader,但我不知道该怎么做

[Fact]
public void ConfigurationReaderGetConfigSettingTest()
{
  // arrange
  string appKeyName = "pathTemp";
  const string currentTempPath = @"C:\Temp\";

  // act
  var mock = new Mock<IConfigurationReader>();
  mock.Setup(x => x.GetAppSetting(It.IsAny<string>())).Returns(currentTempPath);
}
4

0 回答 0