2
0

SocketTest.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // System.Net.Sockets.TcpClientTest.cs
  2. //
  3. // Authors:
  4. // Brad Fitzpatrick ([email protected])
  5. //
  6. // (C) Copyright 2003 Brad Fitzpatrick
  7. //
  8. using System;
  9. using System.Collections;
  10. using System.Net;
  11. using System.Net.Sockets;
  12. using NUnit.Framework;
  13. namespace MonoTests.System.Net.Sockets
  14. {
  15. [TestFixture]
  16. public class SocketTest
  17. {
  18. [Test]
  19. public void EndConnect ()
  20. {
  21. IPAddress ipOne = IPAddress.Parse ("192.168.244.244"); // something bogus
  22. IPEndPoint ipEP = new IPEndPoint (ipOne, 23483); // something bogus
  23. Socket sock = new Socket (ipEP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
  24. IAsyncResult ar = sock.BeginConnect (ipEP, null, null);
  25. bool gotException = false;
  26. try {
  27. sock.EndConnect (ar); // should raise an exception because connect was bogus
  28. } catch {
  29. gotException = true;
  30. }
  31. Assertion.AssertEquals ("A01", gotException, true);
  32. }
  33. [Test]
  34. [ExpectedException (typeof (ArgumentNullException))]
  35. public void SelectEmpty ()
  36. {
  37. ArrayList list = new ArrayList ();
  38. Socket.Select (list, list, list, 1000);
  39. }
  40. }
  41. }