[System/ServiceModel] Fix more hardcoded test ports
[mono.git] / mcs / class / System.ServiceModel / Test / System.ServiceModel / ServiceHostBaseTest.cs
index c7fa92a2f93fb04244fa6b262de0a71fd9749235..a2082bdfa07234b968ab40f11c08d527c5b6e14d 100644 (file)
@@ -131,7 +131,8 @@ namespace MonoTests.System.ServiceModel
                public void InitializeRuntime () {
                        Poker host = new Poker ();
                        host.CallInitializeDescription ();
-                       EndpointAddress address = new EndpointAddress ("http://localhost:8090/");
+                       var port = NetworkHelpers.FindFreePort ();
+                       EndpointAddress address = new EndpointAddress ("http://localhost:" + port + "/");
                        ContractDescription contract = ContractDescription.GetContract (typeof (IMyContract));
                        ServiceEndpoint endpoint = new ServiceEndpoint (contract, new BasicHttpBinding (), address);
                        endpoint.ListenUri = address.Uri;
@@ -377,7 +378,8 @@ namespace MonoTests.System.ServiceModel
                public void AddServiceEndpoint_Directly ()
                {
                        var host = new ServiceHost (typeof (DummyService));
-                       var address = new EndpointAddress ("http://localhost:30158");
+                       var port = NetworkHelpers.FindFreePort ();
+                       var address = new EndpointAddress ("http://localhost:" + port);
                        var binding = new BasicHttpBinding ();
                        var contract = ContractDescription.GetContract (typeof (IDummyService));
                        host.AddServiceEndpoint (new ServiceEndpoint (contract, binding, address));
@@ -398,7 +400,8 @@ namespace MonoTests.System.ServiceModel
                public void AddServiceEndpoint_Directly_NullBinding ()
                {
                        var host = new ServiceHost (typeof (DummyService));
-                       var address = new EndpointAddress ("http://localhost:30158");
+                       var port = NetworkHelpers.FindFreePort ();
+                       var address = new EndpointAddress ("http://localhost:" + port);
                        var contract = ContractDescription.GetContract (typeof (IDummyService));
                        host.AddServiceEndpoint (new ServiceEndpoint (contract, null, address));
                }
@@ -416,7 +419,8 @@ namespace MonoTests.System.ServiceModel
                public void AddServiceEndpoint_Directly_ContractMismatch ()
                {
                        var host = new ServiceHost (typeof (DummyService));
-                       var address = new EndpointAddress ("http://localhost:30158");
+                       var port = NetworkHelpers.FindFreePort ();
+                       var address = new EndpointAddress ("http://localhost:" + port);
                        var binding = new BasicHttpBinding ();
                        var contract = ContractDescription.GetContract (typeof (INotImplementedService));
                        host.AddServiceEndpoint (new ServiceEndpoint (contract, binding, address));