Ejemplo n.º 1
0
 public void TelnetServerShouldTerminateAndReleaseDebuggingContext()
 {
   TelnetServer server;
   using (server = new TelnetServer())
   {
   }
   server.IsListening.Should().BeFalse();
 }
Ejemplo n.º 2
0
        public void TelnetServerShouldTerminateAndReleaseDebuggingContext()
        {
            TelnetServer server;

            using (server = new TelnetServer())
            {
            }
            server.IsListening.Should().BeFalse();
        }
Ejemplo n.º 3
0
 public void ShouldConnect()
 {
   using (TelnetServer server = new TelnetServer())
   {
     using (Client client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
     {
       client.IsConnected.Should().Be(true);
     }
   }
 }
Ejemplo n.º 4
0
 public void ShouldConnect()
 {
     using (TelnetServer server = new TelnetServer())
     {
         using (Client client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
         {
             client.IsConnected.Should().Be(true);
         }
     }
 }
Ejemplo n.º 5
0
 public void ReceiveTimeoutShouldBeDefaultTo0()
 {
     using (TelnetServer server = new TelnetServer())
     {
         using (TcpByteStream sut = new TcpByteStream(server.IPAddress.ToString(), server.Port))
         {
             sut.ReceiveTimeout.Should().Be(0);
         }
     }
 }
Ejemplo n.º 6
0
 public void TcpByteStreamShouldTerminateAndReleaseDebuggingContext()
 {
     using (TelnetServer server = new TelnetServer())
     {
         using (TcpByteStream sut = new TcpByteStream(server.IPAddress.ToString(), server.Port))
         {
             sut.Should().NotBeNull();
         }
     }
 }
Ejemplo n.º 7
0
 public void ShouldConnect()
 {
     using (TelnetServer server = new TelnetServer())
     {
         using (Client client = new Client(server.IPAddress.ToString(), server.Port))
         {
             Assert.AreEqual(client.IsConnected, true);
         }
     }
 }
Ejemplo n.º 8
0
 public void ShouldConnect()
 {
   using (TelnetServer server = new TelnetServer())
   {
     using (Client client = new Client(server.IPAddress.ToString(), server.Port))
     {
       Assert.AreEqual(client.IsConnected, true);
     }
   }
 }
Ejemplo n.º 9
0
 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(":"));
     }
   }
 }
Ejemplo n.º 10
0
        public void TcpByteStreamShouldConstruct()
        {
            using (TelnetServer server = new TelnetServer())
            {
                TcpByteStream sut = null;
                Action        act = () => sut = new TcpByteStream(server.IPAddress.ToString(), server.Port);

                act.ShouldNotThrow();
                sut.Dispose();
            }
        }
Ejemplo n.º 11
0
 public void ShouldTerminateWithAColon()
 {
   using (TelnetServer server = new TelnetServer())
   {
     using (Client client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
     {
       client.IsConnected.Should().Be(true);
       client.TerminatedRead(":", TimeSpan.FromMilliseconds(TimeoutMs)).Should().EndWith(":");
     }
   }
 }
Ejemplo n.º 12
0
 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(":"));
         }
     }
 }
Ejemplo n.º 13
0
 public void ShouldLogin()
 {
     using (TelnetServer server = new TelnetServer())
       {
     using (Client client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
     {
       client.IsConnected.Should().Be(true);
       (client.TryLogin("username", "password", TimeoutMs)).Should().Be(true);
     }
       }
 }
Ejemplo n.º 14
0
 public void ShouldTerminateWithAColon()
 {
     using (TelnetServer server = new TelnetServer())
     {
         using (Client client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
         {
             client.IsConnected.Should().Be(true);
             client.TerminatedRead(":", TimeSpan.FromMilliseconds(TimeoutMs)).Should().EndWith(":");
         }
     }
 }
Ejemplo n.º 15
0
 public void ShouldLogin()
 {
     using (TelnetServer server = new TelnetServer())
     {
         using (Client client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
         {
             client.IsConnected.Should().Be(true);
             (client.TryLogin("username", "password", TimeoutMs)).Should().Be(true);
         }
     }
 }
Ejemplo n.º 16
0
 public async Task ShouldLogin()
 {
     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).ConfigureAwait(false)).Should().Be(true);
         }
     }
 }
Ejemplo n.º 17
0
 public void ShouldLogin()
 {
     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);
         }
     }
 }
Ejemplo n.º 18
0
 public void ShouldBePromptingForAccount()
 {
     using (TelnetServer server = new TelnetServer())
     {
         using (Client client = new Client(server.IPAddress.ToString(), server.Port))
         {
             Assert.AreEqual(client.IsConnected, true);
             string s = client.TerminatedRead("Account:", TimeSpan.FromMilliseconds(TimeoutMs));
             Assert.IsTrue(s.Contains("Account:"));
         }
     }
 }
Ejemplo n.º 19
0
 public void ShouldBePromptingForAccount()
 {
     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:");
         }
     }
 }
Ejemplo n.º 20
0
 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(":"));
         }
     }
 }
Ejemplo n.º 21
0
 public async Task ShouldBePromptingForAccount()
 {
   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));
       s.Should().Contain("Account:");
     }
   }
 }
Ejemplo n.º 22
0
        public void WriteByteShouldNotThrow()
        {
            byte writtenByte = new byte();

            using (TelnetServer server = new TelnetServer())
            {
                using (TcpByteStream sut = new TcpByteStream(server.IPAddress.ToString(), server.Port))
                {
                    Action act = () => sut.WriteByte(writtenByte);
                    act.ShouldNotThrow();
                }
            }
        }
Ejemplo n.º 23
0
        public async Task ShouldBePromptingForAccount()
        {
            using (var server = new TelnetServer())
            {
                using (var client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
                {
                    client.IsConnected.Should().Be(true);
                    var s = await client.TerminatedReadAsync("Account:", TimeSpan.FromMilliseconds(timeoutMs)).ConfigureAwait(false);

                    s.Should().Contain("Account:");
                }
            }
        }
Ejemplo n.º 24
0
 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:"));
         }
     }
 }
Ejemplo n.º 25
0
        public async Task ShouldTerminateWithAColon()
        {
            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(":", TimeSpan.FromMilliseconds(timeoutMs)).ConfigureAwait(false);

                    s.Should().EndWith(":");
                }
            }
        }
Ejemplo n.º 26
0
 public void ShouldBePromptingForPassword()
 {
     using (var server = new TelnetServer())
     {
         using (var client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
         {
             client.IsConnected.Should().Be(true);
             var s = client.TerminatedRead("Account:", TimeSpan.FromMilliseconds(timeoutMs));
             s.Should().Contain("Account:");
             client.WriteLine("username");
             s = client.TerminatedRead("Password:", TimeSpan.FromMilliseconds(timeoutMs));
         }
     }
 }
Ejemplo n.º 27
0
 public void ShouldBePromptingForPassword()
 {
     using (var server = new TelnetServer())
     {
         using (var client = new Client(server.IPAddress.ToString(), server.Port))
         {
             Assert.AreEqual(client.IsConnected, true);
             var s = client.TerminatedRead("Account:", TimeSpan.FromMilliseconds(timeoutMs));
             Assert.IsTrue(s.Contains("Account:"));
             client.WriteLine("username");
             s = client.TerminatedRead("Password:", TimeSpan.FromMilliseconds(timeoutMs));
         }
     }
 }
Ejemplo n.º 28
0
 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));
     }
   }
 }
Ejemplo n.º 29
0
 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:"******"password");
             client.TerminatedRead(">", TimeSpan.FromMilliseconds(TimeoutMs));
         }
     }
 }
Ejemplo n.º 30
0
 public void 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);
             (client.TryLogin("username", "password", TimeoutMs)).Should().Be(true);
             client.WriteLine("show statistic wan2");
             string s = client.TerminatedRead(">", TimeSpan.FromMilliseconds(TimeoutMs));
             s.Should().Contain(">");
             s.Should().Contain("WAN2");
         }
     }
 }
Ejemplo n.º 31
0
 public void 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 = client.TerminatedRead("Account:", TimeSpan.FromMilliseconds(TimeoutMs));
             client.WriteLine("username");
             s = client.TerminatedRead("Password:"******"password");
             s = client.TerminatedRead(">", TimeSpan.FromMilliseconds(TimeoutMs));
         }
     }
 }
Ejemplo n.º 32
0
 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"));
         }
     }
 }
Ejemplo n.º 33
0
 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:"******"password");
       s = await client.TerminatedReadAsync(">", TimeSpan.FromMilliseconds(TimeoutMs));
     }
   }
 }
Ejemplo n.º 34
0
        public async Task ShouldRespondWithWan2InfoRegexTerminated()
        {
            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).ConfigureAwait(false)).Should().Be(true);
                    await client.WriteLine("show statistic wan2").ConfigureAwait(false);

                    string s = await client.TerminatedReadAsync(new Regex(".*>$"), TimeSpan.FromMilliseconds(timeoutMs)).ConfigureAwait(false);

                    s.Should().Contain(">");
                    s.Should().Contain("WAN2");
                }
            }
        }
Ejemplo n.º 35
0
        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);
                    await client.TerminatedReadAsync("Account:", TimeSpan.FromMilliseconds(timeoutMs)).ConfigureAwait(false);

                    await client.WriteLine("username").ConfigureAwait(false);

                    await client.TerminatedReadAsync("Password:"******"password").ConfigureAwait(false);

                    await client.TerminatedReadAsync(">", TimeSpan.FromMilliseconds(timeoutMs)).ConfigureAwait(false);
                }
            }
        }
Ejemplo n.º 36
0
        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);
                }
            }
        }
Ejemplo n.º 37
0
 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(":"));
     }
   }
 }
Ejemplo n.º 38
0
 public void ShouldLogin()
 {
   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);
     }
   }
 }
Ejemplo n.º 39
0
 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);
     }
   }
 }
Ejemplo n.º 40
0
 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"));
     }
   }
 }
Ejemplo n.º 41
0
 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:"******"password");
       client.TerminatedRead(">", TimeSpan.FromMilliseconds(TimeoutMs));
     }
   }
 }
Ejemplo n.º 42
0
 public void ShouldBePromptingForPassword()
 {
   using (TelnetServer server = new TelnetServer())
   {
     using (Client client = new Client(server.IPAddress.ToString(), server.Port))
     {
       Assert.AreEqual(client.IsConnected, true);
       string s = client.TerminatedRead("Account:", TimeSpan.FromMilliseconds(TimeoutMs));
       Assert.IsTrue(s.Contains("Account:"));
       client.WriteLine("username");
       s = client.TerminatedRead("Password:", TimeSpan.FromMilliseconds(TimeoutMs));
     }
   }
 }
Ejemplo n.º 43
0
 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");
     }
   }
 }
Ejemplo n.º 44
0
 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:"));
     }
   }
 }