|
|
@@ -274,6 +274,89 @@ namespace MonoTests.System.ServiceModel.Channels
|
|
|
new Uri ("http://localhost:8080"), String.Empty, ListenUriMode.Unique);
|
|
|
new TextMessageEncodingBindingElement ().BuildChannelListener<IReplyChannel> (ctx);
|
|
|
}
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ [ExpectedException (typeof (InvalidOperationException))]
|
|
|
+ public void BuildChannelListenerWithNoMessageVersion ()
|
|
|
+ {
|
|
|
+ // MyBindingElement overrides GetProperty<T>() without calling GetInnerProperty<T>() and returns null in this case.
|
|
|
+ // ServiceHost.Open() tries to get MessageVersion and raises an error if it cannot get any.
|
|
|
+ // HttpTransportBindingElement can actually provide one.
|
|
|
+ ServiceHost host = new ServiceHost (typeof (FooService));
|
|
|
+ host.AddServiceEndpoint (typeof (IFooService),
|
|
|
+ new CustomBinding (new MyBindingElement (false), new HttpTransportBindingElement ()),
|
|
|
+ "http://localhost:8080");
|
|
|
+ host.Open ();
|
|
|
+ }
|
|
|
+
|
|
|
+ [Test]
|
|
|
+ [ExpectedException (typeof (MyException))]
|
|
|
+ public void BuildChannelListenerWithMessageVersion ()
|
|
|
+ {
|
|
|
+ // MyBindingElement overrides GetProperty<T>() to call GetInnerProperty<T>() (default implementation).
|
|
|
+ // HttpTransportBindingElement should return Soap11.
|
|
|
+ ServiceHost host = new ServiceHost (typeof (FooService));
|
|
|
+ host.AddServiceEndpoint (typeof (IFooService),
|
|
|
+ new CustomBinding (new MyBindingElement (true), new HttpTransportBindingElement ()),
|
|
|
+ "http://localhost:8080");
|
|
|
+ host.Open ();
|
|
|
+ host.Close ();
|
|
|
+ }
|
|
|
+
|
|
|
+ [ServiceContract]
|
|
|
+ public interface IFooService
|
|
|
+ {
|
|
|
+ [OperationContract]
|
|
|
+ string Hello (string msg);
|
|
|
+ }
|
|
|
+ public class FooService : IFooService
|
|
|
+ {
|
|
|
+ public string Hello (string msg)
|
|
|
+ {
|
|
|
+ return "hello";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ class MyBindingElement : BindingElement
|
|
|
+ {
|
|
|
+ public MyBindingElement (bool returnProperty)
|
|
|
+ {
|
|
|
+ return_property = returnProperty;
|
|
|
+ }
|
|
|
+
|
|
|
+ bool return_property;
|
|
|
+
|
|
|
+ public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
|
|
|
+ BindingContext ctx)
|
|
|
+ {
|
|
|
+ throw new NotImplementedException ();
|
|
|
+ }
|
|
|
+
|
|
|
+ public override IChannelListener<TChannel> BuildChannelListener<TChannel> (
|
|
|
+ BindingContext ctx)
|
|
|
+ {
|
|
|
+ throw new MyException ();
|
|
|
+ }
|
|
|
+
|
|
|
+ public override bool CanBuildChannelListener<TChannel> (BindingContext ctx)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public override BindingElement Clone ()
|
|
|
+ {
|
|
|
+ return new MyBindingElement (return_property);
|
|
|
+ }
|
|
|
+
|
|
|
+ public override T GetProperty<T> (BindingContext context)
|
|
|
+ {
|
|
|
+ return return_property ? context.GetInnerProperty<T> () : null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public class MyException : Exception
|
|
|
+ {
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
[DataContract (Namespace = "urn:foo")]
|