You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using System.Reflection;
|
|
|
|
namespace OptionStudy.Next
|
|
{
|
|
/// <summary>
|
|
/// 5.2 配置模型:数据结构之配置字典
|
|
/// </summary>
|
|
public class DataStructurelTest:IDisposable
|
|
{
|
|
private readonly ITestOutputHelper testOutput;
|
|
public DataStructurelTest(ITestOutputHelper testOutputHelper)
|
|
{
|
|
testOutput= testOutputHelper;
|
|
}
|
|
|
|
#region 配置字典:配置源与配置逻辑结构的统一中间实现载体
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 配置字典的类型
|
|
/// </summary>
|
|
[Fact]
|
|
public void ConfigDictionary_DataType__Test()
|
|
{
|
|
//配置字典在 ConfigurationProvider 中默认实现为下面定义的 Data 属性,只能在继承类中可见
|
|
IDictionary<string, string?> Data = new Dictionary<string, string?>()
|
|
{
|
|
|
|
};
|
|
//配置字典的类型
|
|
var configDicDataType = typeof(IDictionary<string, string?>);
|
|
|
|
|
|
//使用反射,获取"配置字典"类型
|
|
|
|
//获取Data属性
|
|
var dataProperty = typeof(ConfigurationProvider).GetProperty("Data", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
|
|
//获取Data属性的类型
|
|
var dataPropertyType = dataProperty?.PropertyType;
|
|
|
|
//断言
|
|
Assert.NotNull(dataProperty);
|
|
Assert.Equal(configDicDataType, dataPropertyType);
|
|
|
|
testOutput.WriteLine("测试配置字典的数据类型");
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|