2 // Copyright (C) 2009 Novell, Inc (http://www.novell.com)
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:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
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.
24 // Andy Hume <andyhume32@yahoo.co.uk>
27 using NUnit.Framework;
30 using System.Drawing.Printing;
32 namespace MonoTests.System.Drawing.Printing
35 public class PaperSizeTest
39 public void PaperSizeKindTest()
41 // set_RawKind seems to accept any value (no ArgEx seen), but get_Kind
42 // returns "Custom" when it's set to a value bigger than the biggest enum.
44 PaperSize ps = new PaperSize ("foo", 100, 100);
48 Assert.AreEqual(PaperKind.Custom, ps.Kind, "Kind #1");
49 Assert.AreEqual(0, ps.RawKind, "RawKind #1");
53 Assert.AreEqual (1 , ps.Height, "get_Height #1");
54 } catch (ArgumentException) {
55 Assert.Fail ("should not have thrown #1");
60 ps.RawKind = (int)PaperKind.A4;
61 Assert.AreEqual (PaperKind.A4, ps.Kind, "Kind #2");
62 Assert.AreEqual ((int)PaperKind.A4, ps.RawKind, "RawKind #2");
66 Assert.Fail("should have thrown #2");
67 } catch (ArgumentException) {
71 ps.RawKind = (int)PaperKind.JapaneseEnvelopeKakuNumber3;
72 Assert.AreEqual (PaperKind.JapaneseEnvelopeKakuNumber3, ps.Kind, "Kind #3");
73 Assert.AreEqual ((int)PaperKind.JapaneseEnvelopeKakuNumber3, ps.RawKind, "RawKind #3");
78 Assert.AreEqual (PaperKind.Custom, ps.Kind, "Kind #4");
79 Assert.AreEqual (999999, ps.RawKind, "RawKind #4");
81 // The properties can be changed only when the *real* Kind is Custom
82 // and not when is 'effectively' Custom.
85 Assert.Fail("should have thrown #4");
86 } catch (ArgumentException) {
90 ps.RawKind = int.MaxValue;
91 Assert.AreEqual (PaperKind.Custom, ps.Kind, "Kind #5");
92 Assert.AreEqual (int.MaxValue, ps.RawKind, "RawKind #5");
95 // Negative -- Looks as if MSFT forgot to check for negative!
97 Assert.AreEqual ((PaperKind)(-1), ps.Kind, "Kind #6");
98 Assert.AreEqual (-1, ps.RawKind, "RawKind #6");
101 ps.RawKind = int.MinValue;
102 Assert.AreEqual ((PaperKind)(int.MinValue), ps.Kind, "Kind #7");
103 Assert.AreEqual (int.MinValue, ps.RawKind, "RawKind #7");
106 // Where's the top limit?
107 ps.RawKind = (int)PaperKind.PrcEnvelopeNumber10Rotated;
108 Assert.AreEqual (PaperKind.PrcEnvelopeNumber10Rotated, ps.Kind, "Kind #8");
109 Assert.AreEqual ((int)PaperKind.PrcEnvelopeNumber10Rotated, ps.RawKind, "RawKind #8");
112 ps.RawKind = 1 + (int)PaperKind.PrcEnvelopeNumber10Rotated;
113 Assert.AreEqual (PaperKind.Custom, ps.Kind, "Kind #9");
114 Assert.AreEqual (1 + (int)PaperKind.PrcEnvelopeNumber10Rotated, ps.RawKind, "RawKind #9");
118 Assert.Fail("should have thrown #9");
119 } catch (ArgumentException) {
123 ps.RawKind = (int)PaperKind.Custom;
124 Assert.AreEqual (PaperKind.Custom, ps.Kind, "Kind #1b");
125 Assert.AreEqual (0, ps.RawKind, "RawKind #1b");
129 Assert.AreEqual (1 , ps.Height, "get_Height #1b");
130 } catch (ArgumentException) {
131 Assert.Fail ("should not have thrown #1b");