}
[Test]
- [Category ("NotWorking")]
public void RunDestinationUnreachableTest ()
+ {
+ RunDestinationUnreachableTest ("BasicHttp", new BasicHttpBinding ());
+ }
+
+ [Test]
+ public void RunDestinationUnreachableTest2 ()
+ {
+ RunDestinationUnreachableTest ("CustomSoap12", new CustomBinding (new HttpTransportBindingElement ()));
+ }
+
+ void RunDestinationUnreachableTest (string label, Binding binding)
{
string address = "http://localhost:37564/";
- var host = OpenHost (address);
-
- var binding = new BasicHttpBinding ();
- var client = new DestinationUnreachableClient (binding, address);
+ var host = OpenHost (address, binding);
try {
+ var client = new DestinationUnreachableClient (binding, address);
client.NotImplementedOperation ();
- Assert.Fail ("ActionNotSupportedException is expected");
+ Assert.Fail (label + " ActionNotSupportedException is expected");
} catch (ActionNotSupportedException) {
// catching it instead of ExpectedException to distinguish errors at service side.
+ } finally {
+ host.Close ();
}
}
- ServiceHost OpenHost (string address)
+ ServiceHost OpenHost (string address, Binding binding)
{
var baseAddresses = new Uri[] { new Uri(address) };
var host = new ServiceHost (typeof (DummyService), baseAddresses);
- var basicBinding = new BasicHttpBinding ();
- host.AddServiceEndpoint (typeof (IDummyService), basicBinding, new Uri ("", UriKind.Relative));
+ host.AddServiceEndpoint (typeof (IDummyService), binding, new Uri ("", UriKind.Relative));
host.Open ();
return host;
}
+#if NET_4_0
+ [Test]
+ public void AddServiceEndpoint_Directly ()
+ {
+ var host = new ServiceHost (typeof (DummyService));
+ var address = new EndpointAddress ("http://localhost:8080");
+ var binding = new BasicHttpBinding ();
+ var contract = ContractDescription.GetContract (typeof (IDummyService));
+ host.AddServiceEndpoint (new ServiceEndpoint (contract, binding, address));
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddServiceEndpoint_Directly_NullAddress ()
+ {
+ var host = new ServiceHost (typeof (DummyService));
+ var binding = new BasicHttpBinding ();
+ var contract = ContractDescription.GetContract (typeof (IDummyService));
+ host.AddServiceEndpoint (new ServiceEndpoint (contract, binding, null));
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddServiceEndpoint_Directly_NullBinding ()
+ {
+ var host = new ServiceHost (typeof (DummyService));
+ var address = new EndpointAddress ("http://localhost:8080");
+ var contract = ContractDescription.GetContract (typeof (IDummyService));
+ host.AddServiceEndpoint (new ServiceEndpoint (contract, null, address));
+ }
+
+ [Test]
+ [ExpectedException (typeof (ArgumentException))]
+ public void AddServiceMetadataEndpoint ()
+ {
+ var host = new ServiceHost (typeof (DummyService));
+ host.AddServiceEndpoint (new ServiceMetadataEndpoint ());
+ }
+
+ [Test]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void AddServiceEndpoint_Directly_ContractMismatch ()
+ {
+ var host = new ServiceHost (typeof (DummyService));
+ var address = new EndpointAddress ("http://localhost:8080");
+ var binding = new BasicHttpBinding ();
+ var contract = ContractDescription.GetContract (typeof (INotImplementedService));
+ host.AddServiceEndpoint (new ServiceEndpoint (contract, binding, address));
+ }
+#endif
+
#region helpers
public enum Stage