[System/ServiceModel] Fix more hardcoded test ports
[mono.git] / mcs / class / System.ServiceModel.Web / Test / System.ServiceModel.Dispatcher / WebHttpDispatchOperationSelectorTest.cs
index bb4593ac99e17df7673ff885f44be428c02be00e..d99036dfdbde7bac5fd3dffce71cd67cd3371398 100644 (file)
@@ -39,6 +39,8 @@ using System.Text;
 using System.Xml;
 using NUnit.Framework;
 
+using MonoTests.Helpers;
+
 namespace MonoTests.System.ServiceModel.Dispatcher
 {
        [TestFixture]
@@ -257,12 +259,13 @@ namespace MonoTests.System.ServiceModel.Dispatcher
                public void WebMessageFormats ()
                {
                        var host = new WebServiceHost (typeof (Hello));
-                       host.AddServiceEndpoint (typeof (IHello), new WebHttpBinding (), "http://localhost:37564/");
+                       var port = NetworkHelpers.FindFreePort ();
+                       host.AddServiceEndpoint (typeof (IHello), new WebHttpBinding (), "http://localhost:" + port + "/");
                        host.Description.Behaviors.Find<ServiceDebugBehavior> ().IncludeExceptionDetailInFaults = true;
                        host.Open ();
                        try {
                                // run client
-                               using (ChannelFactory<IHello> factory = new ChannelFactory<IHello> (new WebHttpBinding (), "http://localhost:37564/"))
+                               using (ChannelFactory<IHello> factory = new ChannelFactory<IHello> (new WebHttpBinding (), "http://localhost:" + port + "/"))
                                {
                                        factory.Endpoint.Behaviors.Add (new WebHttpBehavior ());
                                        IHello h = factory.CreateChannel ();