当前位置: 首页>>代码示例>>C#>>正文


C# Host.SetDown方法代码示例

本文整理汇总了C#中Host.SetDown方法的典型用法代码示例。如果您正苦于以下问题:C# Host.SetDown方法的具体用法?C# Host.SetDown怎么用?C# Host.SetDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Host的用法示例。


在下文中一共展示了Host.SetDown方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetDown_Should_Get_The_Next_Delay_Once_The_Time_Passes

 public void SetDown_Should_Get_The_Next_Delay_Once_The_Time_Passes()
 {
     var policy = new CountReconnectionPolicy(3000);
     var host = new Host(Address, policy);
     TestHelper.ParallelInvoke(() =>
     {
         host.SetDown();
     }, 5);
     //Should call the Schedule#NextDelayMs()
     Assert.AreEqual(1, policy.CallsCount);
     //SetDown should do nothing as the time has not passed
     host.SetDown();
     Assert.AreEqual(1, policy.CallsCount);
     Thread.Sleep(3000);
     Assert.True(host.IsConsiderablyUp);
     //The nextUpTime passed
     TestHelper.ParallelInvoke(() =>
     {
         host.SetDown();
     }, 5);
     Assert.AreEqual(2, policy.CallsCount);
 }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:22,代码来源:HostTests.cs

示例2: BringUpIfDown_Should_Allow_Multiple_Concurrent_Calls

 public void BringUpIfDown_Should_Allow_Multiple_Concurrent_Calls()
 {
     var policy = new CountReconnectionPolicy(100);
     var host = new Host(Address, policy);
     var counter = 0;
     host.Up += _ => Interlocked.Increment(ref counter);
     host.SetDown();
     TestHelper.ParallelInvoke(() =>
     {
         host.BringUpIfDown();
     }, 100);
     //Should fire event only once
     Assert.AreEqual(1, counter);
 }
开发者ID:mtf30rob,项目名称:csharp-driver,代码行数:14,代码来源:HostTests.cs

示例3: BringUpIfDown_Resets_Attempt_Reconnection_Flag

 public void BringUpIfDown_Resets_Attempt_Reconnection_Flag()
 {
     var policy = new CountReconnectionPolicy(long.MaxValue);
     var host = new Host(Address, policy);
     host.SetDown();
     Assert.True(host.SetAttemptingReconnection());
     //Next times it should be false
     Assert.False(host.SetAttemptingReconnection());
     Assert.False(host.SetAttemptingReconnection());
     Assert.False(host.SetAttemptingReconnection());
     host.BringUpIfDown();
     //next time should be allowed
     Assert.True(host.SetAttemptingReconnection());
 }
开发者ID:codeweavers,项目名称:csharp-driver,代码行数:14,代码来源:HostTests.cs


注:本文中的Host.SetDown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。