public void Countries_GetById_Tests() { // Arrange & act var country = AddressRegion.GetById("CN"); // Assert Assert.IsTrue(country?.Currency == "CNY"); }
/// <summary> /// Constructor /// 构造函数 /// </summary> /// <param name="httpClient">Http client, use IHttpClientFactory to create, services.AddHttpClient</param> /// <param name="smsUser">SMS User</param> /// <param name="smsKey">SMS key</param> /// <param name="secureManager">Secure manager</param> public SMSClient(HttpClient httpClient, IConfigurationSection section, Func <string, string>?secureManager = null) : this( httpClient, CryptographyUtils.UnsealData(section.GetValue <string>("SMSUser"), secureManager), CryptographyUtils.UnsealData(section.GetValue <string>("SMSKey"), secureManager), AddressRegion.GetById(section.GetValue <string>("Region")) ?? AddressRegion.CN ) { // var templates = section.GetSection("Templates").Get<TemplateItem[]>(); var templates = section.GetSection("Templates").GetChildren().Select(item => new TemplateItem( Enum.Parse <TemplateKind>(item.GetValue <string>("Kind")), item.GetValue <string>("TemplateId"), item.GetValue <string>("EndPoint"), item.GetValue <string>("Region"), item.GetValue <string>("Language"), item.GetValue <string>("Signature"), item.GetValue("Default", false) )); AddTemplates(templates); }