本文整理汇总了C#中Config.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# Config.Validate方法的具体用法?C# Config.Validate怎么用?C# Config.Validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config.Validate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestClone
public void TestClone()
{
var c = new Config();
var backoffStrategy = new FullJitterStrategy();
var tlsConfig = new TlsConfig();
c.Set("dial_timeout", "50ms");
c.Set("read_timeout", "5m");
c.Set("heartbeat_interval", "2s");
c.Set("rdy_redistribute_interval", "3s");
c.Set("backoff_strategy", backoffStrategy);
c.Set("rdy_redistribute_on_idle", true);
c.Set("tls_config", tlsConfig);
c.Validate();
var c2 = c.Clone();
Assert.AreEqual(TimeSpan.FromMilliseconds(50), c2.DialTimeout, "dial_timeout");
Assert.AreEqual(TimeSpan.FromMinutes(5), c2.ReadTimeout, "read_timeout");
Assert.AreEqual(TimeSpan.FromSeconds(10), c2.WriteTimeout, "write_timeout");
Assert.AreEqual(TimeSpan.FromSeconds(60), c2.LookupdPollInterval, "lookupd_poll_interval");
Assert.AreEqual(0.3, c2.LookupdPollJitter, "lookupd_poll_jitter");
Assert.AreEqual(TimeSpan.FromMinutes(15), c2.MaxRequeueDelay, "max_requeue_delay");
Assert.AreEqual(TimeSpan.FromSeconds(90), c2.DefaultRequeueDelay, "default_requeue_delay");
Assert.AreEqual(backoffStrategy, c2.BackoffStrategy, "backoff_strategy");
Assert.AreEqual(TimeSpan.FromMinutes(2), c2.MaxBackoffDuration, "max_backoff_duration");
Assert.AreEqual(TimeSpan.FromSeconds(1), c2.BackoffMultiplier, "backoff_multiplier");
Assert.AreEqual(5, c2.MaxAttempts, "max_attempts");
Assert.AreEqual(TimeSpan.FromSeconds(10), c2.LowRdyIdleTimeout, "low_rdy_idle_timeout");
Assert.AreEqual(TimeSpan.FromSeconds(3), c2.RDYRedistributeInterval, "rdy_redistribute_interval");
Assert.AreEqual(true, c2.RDYRedistributeOnIdle, "rdy_redistribute_on_idle");
Assert.AreEqual(OS.Hostname().Split('.')[0], c2.ClientID, "client_id");
Assert.AreEqual(OS.Hostname(), c2.Hostname, "hostname");
Assert.AreEqual(string.Format("{0}/{1}", ClientInfo.ClientName, ClientInfo.Version), c2.UserAgent, "user_agent");
Assert.AreEqual(TimeSpan.FromSeconds(2), c2.HeartbeatInterval, "heartbeat_interval");
Assert.AreEqual(0, c2.SampleRate, "sample_rate");
Assert.AreEqual(tlsConfig, c2.TlsConfig, "tls_config");
//Assert.AreEqual(false, c2.Deflate, "deflate"); // TODO: Deflate
//Assert.AreEqual(6, c2.DeflateLevel, "deflate_level"); // TODO: Deflate
//Assert.AreEqual(false, c2.Snappy, "snappy"); // TODO: Snappy
Assert.AreEqual(16384, c2.OutputBufferSize, "output_buffer_size");
Assert.AreEqual(TimeSpan.FromMilliseconds(250), c2.OutputBufferTimeout, "output_buffer_timeout");
Assert.AreEqual(1, c2.MaxInFlight, "max_in_flight");
Assert.AreEqual(TimeSpan.Zero, c2.MessageTimeout, "msg_timeout");
Assert.IsNull(c2.AuthSecret, "auth_secret");
}
示例2: TestHeartbeatLessThanReadTimeout
public void TestHeartbeatLessThanReadTimeout()
{
var c = new Config();
c.Set("read_timeout", "5m");
c.Set("heartbeat_interval", "2s");
c.Validate();
c.Set("read_timeout", "2s");
c.Set("heartbeat_interval", "5m");
Assert.Throws<Exception>(c.Validate);
}
示例3: TestConfigValidateError
public void TestConfigValidateError()
{
var c = new Config();
Assert.Throws<Exception>(() => c.Set("max_backoff_duration", "24h"));
// property wasn't set, state should still be ok
c.Validate();
// test MaxBackoffDuration validation
c.MaxBackoffDuration = TimeSpan.FromHours(24);
Assert.AreEqual(TimeSpan.FromHours(24), c.MaxBackoffDuration);
Assert.Throws<Exception>(c.Validate);
// reset to good state
c.MaxBackoffDuration = TimeSpan.FromSeconds(60);
c.Validate();
// make sure another bad value and call to Validate still throws after the good Validate
c.MaxBackoffDuration = TimeSpan.FromHours(24);
Assert.AreEqual(TimeSpan.FromHours(24), c.MaxBackoffDuration);
Assert.Throws<Exception>(c.Validate);
// reset to good state
c.MaxBackoffDuration = TimeSpan.FromSeconds(60);
c.Validate();
// test null BackoffStrategy validation
c.BackoffStrategy = null;
Assert.IsNull(c.BackoffStrategy);
Assert.Throws<Exception>(c.Validate);
}
示例4: TestConfigValidateDefault
public void TestConfigValidateDefault()
{
var c = new Config();
c.Validate();
}