Merge pull request #439 from mono-soc-2012/garyb/iconfix
[mono.git] / mcs / class / System.Threading.Tasks.Dataflow / Test / System.Threading.Tasks.Dataflow / DataflowMessageHeaderTest.cs
1 // 
2 // DataflowMessageHeaderTest.cs
3 //  
4 // Author:
5 //       Jérémie "garuma" Laval <jeremie.laval@gmail.com>
6 // 
7 // Copyright (c) 2011 Jérémie "garuma" Laval
8 // 
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
15 // 
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 // 
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // THE SOFTWARE.
26
27 using System;
28 using System.Threading.Tasks.Dataflow;
29
30 using NUnit.Framework;
31
32 namespace MonoTests.System.Threading.Tasks.Dataflow
33 {
34         [TestFixture]
35         public class DataflowMessageHeaderTest
36         {
37                 [Test]
38                 public void EqualityTest ()
39                 {
40                         var header1 = new DataflowMessageHeader (2);
41                         var header2 = new DataflowMessageHeader (5);
42                         var header3 = new DataflowMessageHeader (2);
43
44                         Assert.AreEqual (header1, header1);
45                         Assert.AreEqual (header1.GetHashCode (), header1.GetHashCode ());
46                         Assert.AreEqual (header1, header3);
47                         Assert.AreEqual (header1.GetHashCode (), header3.GetHashCode ());
48                         Assert.AreNotEqual (header1, header2);
49                         Assert.AreNotEqual (header1.GetHashCode (), header2.GetHashCode ());
50                 }
51
52                 [Test]
53                 public void ValidityTest ()
54                 {
55                         var header1 = new DataflowMessageHeader ();
56                         var header2 = new DataflowMessageHeader (2);
57                         var header3 = new DataflowMessageHeader (-2);
58
59                         Assert.IsFalse (header1.IsValid);
60                         Assert.IsTrue (header2.IsValid);
61                         Assert.IsTrue (header3.IsValid);
62                 }
63
64                 [Test]
65                 public void ZeroIdTest ()
66                 {
67                         AssertEx.Throws<ArgumentException> (() => new DataflowMessageHeader (0));
68                         Assert.AreEqual (0, new DataflowMessageHeader ().Id);
69                 }
70         }
71 }