本文整理汇总了C#中ConfigurationBuilder.GetBasePath方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationBuilder.GetBasePath方法的具体用法?C# ConfigurationBuilder.GetBasePath怎么用?C# ConfigurationBuilder.GetBasePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigurationBuilder
的用法示例。
在下文中一共展示了ConfigurationBuilder.GetBasePath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBasePath_ReturnEmptyIfNotSet
public void GetBasePath_ReturnEmptyIfNotSet()
{
// Arrange
var builder = new ConfigurationBuilder();
// Act
var actualPath = builder.GetBasePath();
// Assert
Assert.Equal(string.Empty, actualPath);
}
示例2: GetBasePath_ReturnBaseBathIfSet
public void GetBasePath_ReturnBaseBathIfSet()
{
// Arrange
var testDir = Path.GetDirectoryName(Path.GetTempFileName());
var builder = new ConfigurationBuilder();
builder.SetBasePath(testDir);
// Act
var actualPath = builder.GetBasePath();
// Assert
Assert.Equal(testDir, actualPath);
}
示例3: GetBasePath_ReturnBaseDirectoryIfNotSet
public void GetBasePath_ReturnBaseDirectoryIfNotSet()
{
// Arrange
var configurationBuilder = new ConfigurationBuilder();
// Act
var actualPath = configurationBuilder.GetBasePath();
string expectedPath = string.Empty;
#if DNXCORE50
expectedPath = AppContext.BaseDirectory;
#else
expectedPath = AppDomain.CurrentDomain.GetData("APP_CONTEXT_BASE_DIRECTORY") as string ??
AppDomain.CurrentDomain.BaseDirectory ?? string.Empty;
#endif
// Assert
Assert.Equal(expectedPath, actualPath);
}