2009-07-11 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing.Printing / PageSourceTest.cs
1 //
2 // Copyright (C) 2009 Novell, Inc (http://www.novell.com)
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 //
23 // Author:
24 //      Andy Hume <andyhume32@yahoo.co.uk>
25 //
26
27 using NUnit.Framework;
28 using System;
29 using System.Drawing;
30 using System.Drawing.Printing;
31
32 namespace MonoTests.System.Drawing.Printing
33 {       
34         [TestFixture]
35         public class PaperSourceTest
36         {
37 #if NET_2_0
38                 [Test]
39                 public void KindTest ()
40                 {
41                         PaperSource ps = new PaperSource ();
42
43                         //
44                         // Set Custom
45                         ps.RawKind = (int)PaperSourceKind.Custom;
46                         Assert.AreEqual (PaperSourceKind.Custom, ps.Kind, "Kind #8");
47                         Assert.AreEqual (257, ps.RawKind, "RawKind #8");
48
49                         //
50                         // An integer value of 256 and above returns Custom (0x257)
51                         ps.RawKind = 256;
52                         Assert.AreEqual (256, ps.RawKind, "out: #" + 256);
53                         Assert.AreEqual (PaperSourceKind.Custom, ps.Kind, "kind is custom: #" + 256);
54
55                         //
56                         // Zero
57                         ps.RawKind = 0;
58                         Assert.AreEqual ((PaperSourceKind)0, ps.Kind, "Kind #1");
59                         Assert.AreEqual (0, ps.RawKind, "RawKind #1");
60
61                         //
62                         // Well-known
63                         ps.RawKind = (int)PaperSourceKind.Upper;
64                         Assert.AreEqual (PaperSourceKind.Upper, ps.Kind, "Kind #2");
65                         Assert.AreEqual ((int)PaperSourceKind.Upper, ps.RawKind, "RawKind #2");
66
67                         //
68                         ps.RawKind = (int)PaperSourceKind.FormSource;
69                         Assert.AreEqual (PaperSourceKind.FormSource, ps.Kind, "Kind #3");
70                         Assert.AreEqual ((int)PaperSourceKind.FormSource, ps.RawKind, "RawKind #3");
71
72                         //
73                         // Too Big
74                         ps.RawKind = 999999;
75                         Assert.AreEqual (PaperSourceKind.Custom, ps.Kind, "Kind #4");
76                         Assert.AreEqual (999999, ps.RawKind, "RawKind #4");
77
78                         //
79                         ps.RawKind = int.MaxValue;
80                         Assert.AreEqual (PaperSourceKind.Custom, ps.Kind, "Kind #5");
81                         Assert.AreEqual (int.MaxValue, ps.RawKind, "RawKind #5");
82
83                         //
84                         // Negative -- Looks as if MSFT forgot to check for negative!
85                         ps.RawKind = -1;
86                         Assert.AreEqual ((PaperSourceKind)(-1), ps.Kind, "Kind #6");
87                         Assert.AreEqual (-1, ps.RawKind, "RawKind #6");
88
89                         //
90                         ps.RawKind = int.MinValue;
91                         Assert.AreEqual ((PaperSourceKind)(int.MinValue), ps.Kind, "Kind #7");
92                         Assert.AreEqual (int.MinValue, ps.RawKind, "RawKind #7");
93                 }
94 #endif
95
96         }
97
98 }
99