本文整理汇总了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));
}
}
}
示例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));
}
}
}
示例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"));
}
}
}
示例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));
}
}
}
示例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");
}
}
}
示例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);
}
}
}