[bcl] Fix a few hardcoded socket ports in tests (#5471)
[mono.git] / mcs / class / System.ServiceModel / Test / FeatureBased / TestFixtureBase.cs
index 211627b39c6f8ea78cc26519c8941362fb3ac6c1..80513455ec1ab771029d2573cc94f12ab9bfae9f 100644 (file)
@@ -14,14 +14,17 @@ using MonoTests.stand_alone.WebHarness;
 using System.ServiceModel.Dispatcher;
 using System.Collections.ObjectModel;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.Features
 {
        public class Configuration
        {
                static Configuration() {
+                       var port = NetworkHelpers.FindFreePort ();
                        onlyServers = Boolean.Parse (ConfigurationManager.AppSettings ["onlyServers"]  ?? "false");
                        onlyClients = Boolean.Parse (ConfigurationManager.AppSettings ["onlyClients"]  ?? "false");
-                       endpointBase = ConfigurationManager.AppSettings ["endpointBase"] ?? "http://localhost:9999/";
+                       endpointBase = ConfigurationManager.AppSettings ["endpointBase"] ?? $"http://localhost:{port}/";
                        if (!endpointBase.EndsWith ("/"))
                                endpointBase = endpointBase + '/';
                        logMessages = Boolean.Parse (ConfigurationManager.AppSettings ["logMessages"] ?? "false");