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


C# Client.WriteLine方法代码示例

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


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

示例1: ShouldPromptForInput

 public async Task ShouldPromptForInput()
 {
   using (TelnetServer server = new TelnetServer())
   {
     using (Client client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
     {
       client.IsConnected.Should().Be(true);
       string s = await client.TerminatedReadAsync("Account:", TimeSpan.FromMilliseconds(TimeoutMs));
       client.WriteLine("username");
       s = await client.TerminatedReadAsync("Password:", TimeSpan.FromMilliseconds(TimeoutMs));
       client.WriteLine("password");
       s = await client.TerminatedReadAsync(">", TimeSpan.FromMilliseconds(TimeoutMs));
     }
   }
 }
开发者ID:noelhx,项目名称:Telnet,代码行数:15,代码来源:WithClient.cs

示例2: ShouldBePromptingForPassword

 public void ShouldBePromptingForPassword()
 {
   using (TelnetServer server = new TelnetServer())
   {
     using (Client client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
     {
       client.IsConnected.Should().Be(true);
       string s = client.TerminatedRead("Account:", TimeSpan.FromMilliseconds(TimeoutMs));
       s.Should().Contain("Account:");
       client.WriteLine("username");
       s = client.TerminatedRead("Password:", TimeSpan.FromMilliseconds(TimeoutMs));
     }
   }
 }
开发者ID:fireball87,项目名称:Telnet,代码行数:14,代码来源:WithClient.cs

示例3: ShouldRespondWithWan2Info

 public void ShouldRespondWithWan2Info()
 {
   using (TelnetServer server = new TelnetServer())
   {
     using (Client client = new Client(server.IPAddress.ToString(), server.Port))
     {
       Assert.AreEqual(client.IsConnected, true);
       Assert.AreEqual(client.TryLogin("username", "password", TimeoutMs), true);
       client.WriteLine("show statistic wan2");
       string s = client.TerminatedRead(">", TimeSpan.FromMilliseconds(TimeoutMs));
       Assert.IsTrue(s.Contains(">"));
       Assert.IsTrue(s.Contains("WAN2"));
     }
   }
 }
开发者ID:fireball87,项目名称:Telnet,代码行数:15,代码来源:WithClient.cs

示例4: ShouldPromptForInput

 public void ShouldPromptForInput()
 {
   using (TelnetServer server = new TelnetServer())
   {
     using (Client client = new Client(server.IPAddress.ToString(), server.Port))
     {
       Assert.AreEqual(client.IsConnected, true);
       client.TerminatedRead("Account:", TimeSpan.FromMilliseconds(TimeoutMs));
       client.WriteLine("username");
       client.TerminatedRead("Password:", TimeSpan.FromMilliseconds(TimeoutMs));
       client.WriteLine("password");
       client.TerminatedRead(">", TimeSpan.FromMilliseconds(TimeoutMs));
     }
   }
 }
开发者ID:fireball87,项目名称:Telnet,代码行数:15,代码来源:WithClient.cs

示例5: ShouldRespondWithWan2Info

 public async Task ShouldRespondWithWan2Info()
 {
   using (TelnetServer server = new TelnetServer())
   {
     using (Client client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
     {
       client.IsConnected.Should().Be(true);
       (await client.TryLoginAsync("username", "password", 1500)).Should().Be(true);
       client.WriteLine("show statistic wan2");
       string s = await client.TerminatedReadAsync(">", TimeSpan.FromMilliseconds(TimeoutMs));
       s.Should().Contain(">");
       s.Should().Contain("WAN2");
     }
   }
 }
开发者ID:noelhx,项目名称:Telnet,代码行数:15,代码来源:WithClient.cs

示例6: ReadmeExample

 public async Task ReadmeExample()
 {
   using (TelnetServer server = new TelnetServer())
   {
     using (Client client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
     {
       client.IsConnected.Should().Be(true);
       (await client.TryLoginAsync("username", "password", TimeoutMs)).Should().Be(true);
       client.WriteLine("show statistic wan2");
       string s = await client.TerminatedReadAsync(">", TimeSpan.FromMilliseconds(TimeoutMs));
       s.Should().Contain(">");
       s.Should().Contain("WAN2");
       System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex("(?!WAN2 total TX: )([0-9.]*)(?! GB ,RX: )([0-9.]*)(?= GB)");
       regEx.IsMatch(s).Should().Be(true);
       MatchCollection matches = regEx.Matches(s);
       decimal tx = decimal.Parse(matches[0].Value);
       decimal rx = decimal.Parse(matches[1].Value);
       (tx + rx).Should().BeLessThan(50);
     }
   }
 }
开发者ID:noelhx,项目名称:Telnet,代码行数:21,代码来源:WithClient.cs


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