2 // DataflowMessageHeaderTest.cs
5 // Jérémie "garuma" Laval <jeremie.laval@gmail.com>
7 // Copyright (c) 2011 Jérémie "garuma" Laval
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:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
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
28 using System.Threading.Tasks.Dataflow;
30 using NUnit.Framework;
32 namespace MonoTests.System.Threading.Tasks.Dataflow
35 public class DataflowMessageHeaderTest
38 public void EqualityTest ()
40 var header1 = new DataflowMessageHeader (2);
41 var header2 = new DataflowMessageHeader (5);
42 var header3 = new DataflowMessageHeader (2);
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 ());
53 public void ValidityTest ()
55 var header1 = new DataflowMessageHeader ();
56 var header2 = new DataflowMessageHeader (2);
57 var header3 = new DataflowMessageHeader (-2);
59 Assert.IsFalse (header1.IsValid);
60 Assert.IsTrue (header2.IsValid);
61 Assert.IsTrue (header3.IsValid);
65 public void ZeroIdTest ()
67 AssertEx.Throws<ArgumentException> (() => new DataflowMessageHeader (0));
68 Assert.AreEqual (0, new DataflowMessageHeader ().Id);