NetMsmqBindingTest.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // NetMsmqBindingTest.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2007 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.Net.Security;
  31. using System.ServiceModel;
  32. using System.ServiceModel.Channels;
  33. using System.ServiceModel.Security;
  34. using NUnit.Framework;
  35. namespace MonoTests.System.ServiceModel
  36. {
  37. [TestFixture]
  38. public class NetMsmqBindingTest
  39. {
  40. [Test]
  41. public void DefaultValues ()
  42. {
  43. NetMsmqBinding b = new NetMsmqBinding ();
  44. Assert.AreEqual (EnvelopeVersion.Soap12, b.EnvelopeVersion, "#1");
  45. Assert.AreEqual (0x80000, b.MaxBufferPoolSize, "#2");
  46. Assert.AreEqual (QueueTransferProtocol.Native, b.QueueTransferProtocol, "#2");
  47. Assert.IsNotNull (b.ReaderQuotas, "#3");
  48. Assert.IsFalse (b.UseActiveDirectory, "#4");
  49. Assert.IsNull (b.CustomDeadLetterQueue, "#5");
  50. Assert.AreEqual (DeadLetterQueue.System, b.DeadLetterQueue, "#6");
  51. Assert.IsTrue (b.Durable, "#7");
  52. Assert.IsTrue (b.ExactlyOnce, "#8");
  53. Assert.AreEqual (0x10000, b.MaxReceivedMessageSize, "#9");
  54. Assert.AreEqual (2, b.MaxRetryCycles, "#10");
  55. Assert.AreEqual (ReceiveErrorHandling.Fault, b.ReceiveErrorHandling, "#11");
  56. Assert.AreEqual (5, b.ReceiveRetryCount, "#12");
  57. // hmm, it is documented as 10 minutes but ...
  58. Assert.AreEqual (TimeSpan.FromMinutes (30), b.RetryCycleDelay, "#13");
  59. Assert.AreEqual ("net.msmq", b.Scheme, "#14");
  60. Assert.AreEqual (TimeSpan.FromDays (1), b.TimeToLive, "#15");
  61. Assert.IsFalse (b.UseMsmqTracing, "#16");
  62. Assert.IsFalse (b.UseSourceJournal, "#17");
  63. }
  64. /*
  65. [Test]
  66. [ExpectedException (typeof (InvalidOperationException))]
  67. public void DefaultValueSecurityModeMessageError ()
  68. {
  69. NetMsmqBinding b = new NetMsmqBinding (BasicHttpSecurityMode.Message);
  70. // "BasicHttp binding requires that NetMsmqBinding.Security.Message.ClientCredentialType be equivalent to the BasicHttpMessageCredentialType.Certificate credential type for secure messages. Select Transport or TransportWithMessageCredential security for UserName credentials."
  71. b.CreateBindingElements ();
  72. }
  73. */
  74. [Test]
  75. public void CreateBindingElements ()
  76. {
  77. BindingElementCollection bl = new NetMsmqBinding ().CreateBindingElements ();
  78. Assert.AreEqual (2, bl.Count, "#1");
  79. Assert.IsTrue (bl [0] is BinaryMessageEncodingBindingElement, "#2");
  80. Assert.IsTrue (bl [1] is MsmqTransportBindingElement, "#3");
  81. }
  82. /*
  83. [Test]
  84. public void MessageEncoding ()
  85. {
  86. NetMsmqBinding b = new NetMsmqBinding ();
  87. foreach (BindingElement be in b.CreateBindingElements ()) {
  88. MessageEncodingBindingElement mbe =
  89. be as MessageEncodingBindingElement;
  90. if (mbe != null) {
  91. MessageEncoderFactory f = mbe.CreateMessageEncoderFactory ();
  92. MessageEncoder e = f.Encoder;
  93. Assert.AreEqual (typeof (TextMessageEncodingBindingElement), mbe.GetType (), "#1-1");
  94. Assert.AreEqual (MessageVersion.Soap11, f.MessageVersion, "#2-1");
  95. Assert.AreEqual ("text/xml; charset=utf-8", e.ContentType, "#3-1");
  96. Assert.AreEqual ("text/xml", e.MediaType, "#3-2");
  97. return;
  98. }
  99. }
  100. Assert.Fail ("No message encodiing binding element.");
  101. }
  102. */
  103. }
  104. }