BindingElementTest.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. //
  2. // BindingElementTest.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2005 Novell, Inc. http://www.novell.com
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Collections.ObjectModel;
  31. using System.Net.Security;
  32. using System.ServiceModel;
  33. using System.ServiceModel.Channels;
  34. using System.ServiceModel.Description;
  35. using System.ServiceModel.Security;
  36. using NUnit.Framework;
  37. namespace MonoTests.System.ServiceModel.Channels
  38. {
  39. [TestFixture]
  40. public class BindingElementTest
  41. {
  42. class MyChannelFactory<TChannel>
  43. : ChannelFactoryBase<TChannel>
  44. {
  45. public MyChannelFactory ()
  46. : base ()
  47. {
  48. }
  49. protected override TChannel OnCreateChannel (EndpointAddress address, Uri via)
  50. {
  51. throw new NotSupportedException ();
  52. }
  53. protected override IAsyncResult OnBeginOpen (
  54. TimeSpan timeout, AsyncCallback callback, object state)
  55. {
  56. throw new NotImplementedException ();
  57. }
  58. protected override void OnEndOpen (IAsyncResult result)
  59. {
  60. throw new NotImplementedException ();
  61. }
  62. protected override void OnOpen (TimeSpan timeout)
  63. {
  64. throw new NotImplementedException ();
  65. }
  66. }
  67. class MyChannelListener<TChannel>
  68. : ChannelListenerBase<TChannel>
  69. where TChannel : class, IChannel
  70. {
  71. public MyChannelListener ()
  72. : base ()
  73. {
  74. }
  75. public override Uri Uri {
  76. get { throw new NotImplementedException (); }
  77. }
  78. protected override IAsyncResult OnBeginAcceptChannel (
  79. TimeSpan timeout, AsyncCallback callback, object state)
  80. {
  81. throw new NotImplementedException ();
  82. }
  83. protected override TChannel OnAcceptChannel (TimeSpan timeout)
  84. {
  85. throw new NotImplementedException ();
  86. }
  87. protected override TChannel OnEndAcceptChannel (IAsyncResult result)
  88. {
  89. throw new NotImplementedException ();
  90. }
  91. protected override IAsyncResult OnBeginWaitForChannel (
  92. TimeSpan timeout, AsyncCallback callback, object state)
  93. {
  94. throw new NotImplementedException ();
  95. }
  96. protected override bool OnEndWaitForChannel (IAsyncResult result)
  97. {
  98. throw new NotImplementedException ();
  99. }
  100. protected override bool OnWaitForChannel (TimeSpan timeout)
  101. {
  102. throw new NotImplementedException ();
  103. }
  104. protected override void OnAbort ()
  105. {
  106. throw new NotImplementedException ();
  107. }
  108. protected override IAsyncResult OnBeginClose (
  109. TimeSpan timeout, AsyncCallback callback, object state)
  110. {
  111. throw new NotImplementedException ();
  112. }
  113. protected override IAsyncResult OnBeginOpen (
  114. TimeSpan timeout, AsyncCallback callback, object state)
  115. {
  116. throw new NotImplementedException ();
  117. }
  118. protected override void OnEndClose (IAsyncResult result)
  119. {
  120. throw new NotImplementedException ();
  121. }
  122. protected override void OnEndOpen (IAsyncResult result)
  123. {
  124. throw new NotImplementedException ();
  125. }
  126. protected override void OnClose (TimeSpan timeout)
  127. {
  128. throw new NotImplementedException ();
  129. }
  130. protected override void OnOpen (TimeSpan timeout)
  131. {
  132. }
  133. }
  134. class MyBindingElement : BindingElement
  135. {
  136. public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
  137. BindingContext ctx)
  138. {
  139. return new MyChannelFactory<TChannel> ();
  140. }
  141. public override IChannelListener<TChannel> BuildChannelListener<TChannel> (
  142. BindingContext ctx)
  143. {
  144. return new MyChannelListener<TChannel> ();
  145. }
  146. public override bool CanBuildChannelListener<TChannel> (BindingContext ctx)
  147. {
  148. return true;
  149. }
  150. public override BindingElement Clone ()
  151. {
  152. return new MyBindingElement ();
  153. }
  154. public override T GetProperty<T> (BindingContext context)
  155. {
  156. return null;
  157. }
  158. }
  159. [Test]
  160. [Ignore ("It is even not a test yet.")]
  161. public void BuildChannelFactory ()
  162. {
  163. ServiceHost host = new ServiceHost (typeof (Foo));
  164. host.AddServiceEndpoint (typeof (Foo),
  165. new CustomBinding (new MyBindingElement (),
  166. new HttpTransportBindingElement ()),
  167. "http://localhost:8080");
  168. host.Open ();
  169. }
  170. [ServiceContract]
  171. class Foo
  172. {
  173. [OperationContract]
  174. public void Whee ()
  175. {
  176. }
  177. }
  178. }
  179. }