using System.ServiceModel.Dispatcher;
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.System.ServiceModel
{
[TestFixture]
[Test]
public void AddServiceEndpoint2_4 ()
{
- ServiceHost host = new ServiceHost (typeof (HogeFuga), new Uri ("http://localhost:37564"));
+ var ep = "http://" + NetworkHelpers.LocalEphemeralEndPoint().ToString();
+ ServiceHost host = new ServiceHost (typeof (HogeFuga), new Uri (ep));
var binding = new BasicHttpBinding ();
- host.AddServiceEndpoint (typeof (IHoge), binding, new Uri ("http://localhost:37564"));
- host.AddServiceEndpoint (typeof (IFuga), binding, new Uri ("http://localhost:37564"));
+ host.AddServiceEndpoint (typeof (IHoge), binding, new Uri (ep));
+ host.AddServiceEndpoint (typeof (IFuga), binding, new Uri (ep));
// Use the same binding, results in one ChannelDispatcher (actually two, for metadata/debug behavior).
host.Open ();
host.AddServiceEndpoint ("ISuchTypeDoesNotExist", new BasicHttpBinding (), "rel");
}
+ [Test]
+ public void AddServiceEndpoint7 ()
+ {
+ ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
+ var a = host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "a");
+ Console.WriteLine (a.Address);
+ Assert.AreEqual ("http", a.Address.Uri.Scheme, "#1");
+ Assert.AreEqual ("http://localhost/echo/a", a.Address.Uri.AbsoluteUri, "#2");
+
+ var b = host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "/b");
+ Console.WriteLine (b.Address);
+ Assert.AreEqual ("http", b.Address.Uri.Scheme, "#3");
+ Assert.AreEqual ("http://localhost/echo/b", b.Address.Uri.AbsoluteUri, "#4");
+ }
+
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void AddServiceEndpointMexWithNoImpl ()
[Test]
public void InstanceWithNonSingletonMode ()
{
+ var ep = NetworkHelpers.LocalEphemeralEndPoint().ToString();
ServiceHost host = new ServiceHost (
new NonSingletonService ());
Assert.IsNotNull (host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().GetWellKnownSingleton (), "premise1");
host.AddServiceEndpoint (
typeof (NonSingletonService),
new BasicHttpBinding (),
- new Uri ("http://localhost:37564/s1"));
+ new Uri ("http://" + ep + "/s1"));
// in case Open() didn't fail, we need to close the host.
// And even if Close() caused the expected exception,
[Test]
public void InstanceWithSingletonMode ()
{
+ var ep = NetworkHelpers.LocalEphemeralEndPoint().ToString();
SingletonService instance = new SingletonService ();
ServiceHost host = new ServiceHost (instance);
Assert.IsNotNull (host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().GetWellKnownSingleton (), "#1");
host.AddServiceEndpoint (
typeof (SingletonService),
new BasicHttpBinding (),
- new Uri ("http://localhost:37564/s2"));
+ new Uri ("http://" + ep + "/s2"));
// in case Open() didn't fail, we need to close the host.
// And even if Close() caused the expected exception,