[Tests] Fix Mono.Data.Tds tests on iOS (#5501)
authorManuel de la Pena <v-mandel@microsoft.com>
Fri, 8 Sep 2017 11:05:48 +0000 (13:05 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Fri, 8 Sep 2017 11:05:48 +0000 (13:05 +0200)
* [Tests] Fix Mono.Data.Tds tests on iOS

The modified tests failed on iOS following PR:
https://github.com/xamarin/xamarin-macios/pull/2580 that adds support
for Xharness to run the Mono.Data.Tds on Xamarin.iOS. With the changes
the tests run a expected.

* Close Listener when done.

mcs/class/Mono.Data.Tds/Test/bug-4786.cs

index 91f8a06fc1a16b114f8a00c0b024fa95fcadb853..ed44567b40d019b14b7198a20c623f98a82449b1 100644 (file)
@@ -51,13 +51,10 @@ namespace MonoTests.Mono.Data.Tds
        //require at this point: a listener on port 1433...
 
        try{
-               Socket Listener = new Socket(AddressFamily.InterNetwork, 
-                                         SocketType.Stream,
-                                         ProtocolType.Tcp);
                IPAddress hostIP =Dns.GetHostEntry("localhost").AddressList[0];
-               IPEndPoint ep = new IPEndPoint(hostIP, 1433);
-               Listener.Bind(ep); 
-               Listener.Listen(1);
+        IPEndPoint ep = new IPEndPoint(hostIP, 1433);
+        TcpListener Listener = new TcpListener (ep);
+        Listener.Start ();
        } catch (Exception){
                //ignore
        }
@@ -103,6 +100,7 @@ namespace MonoTests.Mono.Data.Tds
 
        pool.ReleaseConnection(tds);
 
+       Listener.Stop ();
        //exit
     }
   }