2009-07-13 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / Mono.Messaging / Test / Mono.Messaging / MessageBaseTest.cs
1 //
2 // Mono.Messaging.RabbitMQ
3 //
4 // Authors:
5 //        Michael Barker (mike@middlesoft.co.uk)
6 //
7 // (C) 2008 Michael Barker
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 using System;
32 using System.Messaging;
33 using System.Reflection;
34 using Mono.Messaging;
35
36 using NUnit.Framework;
37
38 namespace MonoTests.Mono.Messaging {
39
40         [TestFixture]
41         public class MessageBaseTest {
42                 
43                 [Test]
44                 public void CheckDefaultValues ()
45                 {
46             Type[] types = { 
47                 typeof (IMessage), typeof (object), typeof (IMessageFormatter)
48             };
49                 
50             ConstructorInfo ci = typeof (Message).GetConstructor (
51                 BindingFlags.NonPublic | BindingFlags.Instance, 
52                 Type.DefaultBinder, types, new ParameterModifier[0]);
53                 
54             if (ci == null)
55                 throw new Exception ("ConstructorInfo is null");
56             
57             Message m = (Message) ci.Invoke (new object[] { new MessageBase (), null, null });
58                         
59                         Assert.IsNull (m.Body, "Body default should be Null");
60                         Assert.IsNull (m.Formatter, "Formatter default should null");
61                         
62                         Assert.AreEqual (System.Messaging.AcknowledgeTypes.None, 
63                                         m.AcknowledgeType, 
64                                         "AcknowledgeType default should be None");
65                         Assert.AreEqual (null, m.AdministrationQueue, 
66                                         "AdministrationQueue default should be null");
67                         Assert.AreEqual (0, m.AppSpecific, "AppSpecific default should be 0");
68                         Assert.AreEqual (true, m.AttachSenderId, "AttachSenderId default should be true");
69                         Assert.AreEqual ("Microsoft Base Cryptographic Provider, Ver. 1.0", m.AuthenticationProviderName, 
70                                         "AuthenticationProviderName should default to \"Microsoft Base Cryptographic Provider, Ver. 1.0\"");
71                         Assert.AreEqual (System.Messaging.CryptographicProviderType.RsaFull, 
72                                         m.AuthenticationProviderType, 
73                                         "AuthenticationProviderType should default to RsaFull");
74                         Assert.AreEqual (null, m.BodyStream, "BodyStream should default to null");
75                         Assert.AreEqual (Guid.Empty, m.ConnectorType, "ConnectorType should default to empty");
76                         Assert.AreEqual (null, m.CorrelationId, "CorrelationId should default to null");
77                         Assert.AreEqual (new byte[0], m.DestinationSymmetricKey, 
78                                         "DestinationSymmetricKey should default to an empty array");
79                         Assert.AreEqual (new byte[0], m.DigitalSignature,
80                                         "DigitalSignature default to an empty array");
81                         Assert.AreEqual (System.Messaging.EncryptionAlgorithm.Rc2,
82                                         m.EncryptionAlgorithm,
83                                         "EncryptionAlgorithm should default to Rc2");
84                         Assert.AreEqual (new byte[0], m.Extension, 
85                                         "Extension should default to an empty array");
86                         Assert.AreEqual (System.Messaging.HashAlgorithm.Sha, m.HashAlgorithm, 
87                                         "HashAlgorithm should default to Sha");
88                         Assert.AreEqual (Guid.Empty.ToString () + "\\0", m.Id, "Id should default to Guid.Empty");
89                         Assert.AreEqual ("", m.Label, "Label should default to \"\"");
90                         Assert.AreEqual (false, m.IsFirstInTransaction, "IsFirstInTransaction should default to false");
91                         Assert.AreEqual (false, m.IsLastInTransaction, "IsLastInTransaction should default to false");
92                         Assert.AreEqual (System.Messaging.MessagePriority.Normal, m.Priority,
93                                         "Priority should default to Normal");
94                         Assert.AreEqual (false, m.Recoverable, "Recoverable should default to false");
95                         Assert.AreEqual (null, m.ResponseQueue, "ResponseQueue should default to null");
96                         //Assert.AreEqual (null, m.SecurityContext, "SecurityContext should default to null");
97                         Assert.AreEqual (new byte[0], m.SenderCertificate, 
98                                         "SenderCertificate should default to an empty array");
99                         Assert.AreEqual (Message.InfiniteTimeout, m.TimeToBeReceived,
100                                         "TimeToBeReceived should default to InfiniteTimeout");
101                         Assert.AreEqual (Message.InfiniteTimeout, m.TimeToReachQueue,
102                                         "TimeToReadQueue should default to InfiniteTimeout");
103                         Assert.AreEqual (false, m.UseAuthentication, 
104                                         "UseAuthentication should default to false");
105                         Assert.AreEqual (false, m.UseDeadLetterQueue,
106                                         "UseDeadLetterQueue should default to false");
107                         Assert.AreEqual (false, m.UseEncryption, "Encryption should default to false");
108                         Assert.AreEqual (false, m.UseJournalQueue, 
109                                         "UseJournalQueue should default to false");
110                         Assert.AreEqual (false, m.UseTracing, "UseTracing should default to false");
111                 }
112         }
113 }