NamedPipeTransportBindingElementTest.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //
  2. // NamedPipeTransportBindingElementTest.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2008 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.ObjectModel;
  30. using System.IO;
  31. using System.Net;
  32. using System.Net.Security;
  33. using System.ServiceModel;
  34. using System.ServiceModel.Channels;
  35. using System.ServiceModel.Description;
  36. using System.Threading;
  37. using System.Xml;
  38. using NUnit.Framework;
  39. namespace MonoTests.System.ServiceModel.Channels
  40. {
  41. [TestFixture]
  42. public class NamedPipeTransportBindingElementTest
  43. {
  44. static BindingParameterCollection empty_params =
  45. new BindingParameterCollection ();
  46. [Test]
  47. public void DefaultValues ()
  48. {
  49. NamedPipeTransportBindingElement be =
  50. new NamedPipeTransportBindingElement ();
  51. Assert.AreEqual (TimeSpan.FromSeconds (5), be.ChannelInitializationTimeout, "#1");
  52. Assert.AreEqual (0x2000, be.ConnectionBufferSize, "#2");
  53. Assert.AreEqual (HostNameComparisonMode.StrongWildcard, be.HostNameComparisonMode, "#3");
  54. Assert.AreEqual (0x10000, be.MaxBufferSize, "#4");
  55. Assert.AreEqual (TimeSpan.FromMilliseconds (200), be.MaxOutputDelay, "#5");
  56. Assert.AreEqual (1, be.MaxPendingAccepts, "#6");
  57. Assert.AreEqual (10, be.MaxPendingConnections, "#7");
  58. Assert.AreEqual (TransferMode.Buffered, be.TransferMode, "#8");
  59. Assert.AreEqual ("net.pipe", be.Scheme, "#11");
  60. NamedPipeConnectionPoolSettings pool = be.ConnectionPoolSettings;
  61. Assert.IsNotNull (pool, "#13");
  62. Assert.AreEqual ("default", pool.GroupName, "#14");
  63. Assert.AreEqual (TimeSpan.FromSeconds (120), pool.IdleTimeout, "#15");
  64. Assert.AreEqual (10, pool.MaxOutboundConnectionsPerEndpoint, "#17");
  65. }
  66. [Test]
  67. public void CanBuildChannelFactory ()
  68. {
  69. NamedPipeTransportBindingElement be =
  70. new NamedPipeTransportBindingElement ();
  71. BindingContext ctx = new BindingContext (
  72. new CustomBinding (), empty_params);
  73. Assert.IsFalse (be.CanBuildChannelFactory<IRequestChannel> (ctx), "#1");
  74. Assert.IsFalse (be.CanBuildChannelFactory<IInputChannel> (ctx), "#2");
  75. Assert.IsFalse (be.CanBuildChannelFactory<IReplyChannel> (ctx), "#3");
  76. Assert.IsFalse (be.CanBuildChannelFactory<IOutputChannel> (ctx), "#4");
  77. Assert.IsFalse (be.CanBuildChannelFactory<IRequestSessionChannel> (ctx), "#5");
  78. Assert.IsFalse (be.CanBuildChannelFactory<IInputSessionChannel> (ctx), "#6");
  79. Assert.IsFalse (be.CanBuildChannelFactory<IReplySessionChannel> (ctx), "#7");
  80. Assert.IsFalse (be.CanBuildChannelFactory<IOutputSessionChannel> (ctx), "#8");
  81. // IServiceChannel is not supported
  82. Assert.IsFalse (be.CanBuildChannelFactory<IServiceChannel> (ctx), "#9");
  83. Assert.IsFalse (be.CanBuildChannelFactory<IClientChannel> (ctx), "#10");
  84. Assert.IsTrue (be.CanBuildChannelFactory<IDuplexSessionChannel> (ctx), "#11");
  85. Assert.IsTrue (be.CanBuildChannelFactory<IDuplexSessionChannel> (ctx), "#12");
  86. }
  87. [Test]
  88. public void CanBuildChannelListener ()
  89. {
  90. NamedPipeTransportBindingElement be =
  91. new NamedPipeTransportBindingElement ();
  92. BindingContext ctx = new BindingContext (
  93. new CustomBinding (), empty_params);
  94. Assert.IsFalse (be.CanBuildChannelListener<IReplyChannel> (ctx), "#1");
  95. Assert.IsFalse (be.CanBuildChannelListener<IOutputChannel> (ctx), "#2");
  96. Assert.IsFalse (be.CanBuildChannelListener<IRequestChannel> (ctx), "#3");
  97. Assert.IsFalse (be.CanBuildChannelListener<IInputChannel> (ctx), "#4");
  98. Assert.IsFalse (be.CanBuildChannelListener<IReplySessionChannel> (ctx), "#5");
  99. Assert.IsFalse (be.CanBuildChannelListener<IOutputSessionChannel> (ctx), "#6");
  100. Assert.IsFalse (be.CanBuildChannelListener<IRequestSessionChannel> (ctx), "#7");
  101. Assert.IsFalse (be.CanBuildChannelListener<IInputSessionChannel> (ctx), "#8");
  102. // IServiceChannel is not supported
  103. Assert.IsFalse (be.CanBuildChannelListener<IServiceChannel> (ctx), "#9");
  104. Assert.IsFalse (be.CanBuildChannelListener<IClientChannel> (ctx), "#10");
  105. Assert.IsFalse (be.CanBuildChannelListener<IDuplexChannel> (ctx), "#11");
  106. Assert.IsTrue (be.CanBuildChannelListener<IDuplexSessionChannel> (ctx), "#12");
  107. }
  108. }
  109. }