本文整理汇总了C#中Client.TerminatedRead方法的典型用法代码示例。如果您正苦于以下问题:C# Client.TerminatedRead方法的具体用法?C# Client.TerminatedRead怎么用?C# Client.TerminatedRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client.TerminatedRead方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
}
}
示例2: ShouldTerminateWithAColon
public void ShouldTerminateWithAColon()
{
using (TelnetServer server = new TelnetServer())
{
using (Client client = new Client(server.IPAddress.ToString(), server.Port))
{
Assert.AreEqual(client.IsConnected, true);
Assert.IsTrue(client.TerminatedRead(":", TimeSpan.FromMilliseconds(TimeoutMs)).EndsWith(":"));
}
}
}
示例3: ShouldRegexMatchWithAColon
public void ShouldRegexMatchWithAColon()
{
using (TelnetServer server = new TelnetServer())
{
using (Client client = new Client(server.IPAddress.ToString(), server.Port))
{
Assert.AreEqual(client.IsConnected, true);
Regex regex = new Regex(".*:\r?$", RegexOptions.Multiline);
Assert.IsTrue(client.TerminatedRead(regex, TimeSpan.FromMilliseconds(TimeoutMs)).EndsWith(":"));
}
}
}
示例4: 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"));
}
}
}
示例5: 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));
}
}
}
示例6: ShouldRegexMatchPromptingForAccount
public void ShouldRegexMatchPromptingForAccount()
{
using (TelnetServer server = new TelnetServer())
{
using (Client client = new Client(server.IPAddress.ToString(), server.Port))
{
Assert.AreEqual(client.IsConnected, true);
Regex regex = new Regex(".*Account:\r?$", RegexOptions.Multiline);
string s = client.TerminatedRead(regex, TimeSpan.FromMilliseconds(TimeoutMs));
Assert.IsTrue(s.Contains("Account:"));
}
}
}