Merge pull request #704 from jgagnon/master
[mono.git] / mcs / class / System.ServiceModel / Test / System.ServiceModel.Channels / MessagePropertiesTest.cs
1 //
2 // BindingElementTest.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2009 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.IO;
31 using System.Runtime.Serialization;
32 using System.ServiceModel;
33 using System.ServiceModel.Channels;
34 using System.Text;
35 using System.Xml;
36 using NUnit.Framework;
37
38 namespace MonoTests.System.ServiceModel.Channels
39 {
40         [TestFixture]
41         public class MessagePropertiesTest
42         {
43                 [Test]
44                 public void CopyProperties ()
45                 {
46                         var mp = new MessageProperties ();
47                         var obj = new object ();
48                         var obj2 = new object ();
49                         mp.Add ("FooProperty", obj);
50                         var mp2 = new MessageProperties ();
51                         mp2.Add ("BarProperty", obj2);
52                         mp.CopyProperties (mp2);
53                         Assert.AreEqual (obj, mp ["FooProperty"], "#1");
54                         Assert.AreEqual (obj2, mp ["BarProperty"], "#2");
55                 }
56
57                 [Test]
58                 public void AllowOutputBatching ()
59                 {
60                         var mp = new MessageProperties ();
61                         Assert.IsFalse (mp.AllowOutputBatching, "#0");
62                         mp.AllowOutputBatching = true;
63                         Assert.AreEqual (1, mp.Count, "#1");
64                         foreach (KeyValuePair<string,object> p in mp)
65                                 Assert.AreEqual ("AllowOutputBatching", p.Key, "#2");
66                 }
67
68                 [Test]
69                 public void Encoder ()
70                 {
71                         var mp = new MessageProperties ();
72                         Assert.IsNull (mp.Via, "#0");
73                         mp.Encoder = new TextMessageEncodingBindingElement ().CreateMessageEncoderFactory ().Encoder;
74                         Assert.AreEqual (1, mp.Count, "#1");
75                         foreach (KeyValuePair<string,object> p in mp)
76                                 Assert.AreEqual ("Encoder", p.Key, "#2");
77                 }
78
79                 [Test]
80                 public void Via ()
81                 {
82                         var mp = new MessageProperties ();
83                         Assert.IsNull (mp.Via, "#0");
84                         mp.Via = new Uri ("urn:foo");
85                         Assert.AreEqual (1, mp.Count, "#1");
86                         foreach (KeyValuePair<string,object> p in mp)
87                                 Assert.AreEqual ("Via", p.Key, "#2");
88                 }
89         }
90 }