PageSourceTest.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 <[email protected]>
  25. //
  26. using NUnit.Framework;
  27. using System;
  28. using System.Drawing;
  29. using System.Drawing.Printing;
  30. namespace MonoTests.System.Drawing.Printing
  31. {
  32. [TestFixture]
  33. public class PaperSourceTest
  34. {
  35. #if NET_2_0
  36. [Test]
  37. public void KindTest ()
  38. {
  39. PaperSource ps = new PaperSource ();
  40. //
  41. // Set Custom
  42. ps.RawKind = (int)PaperSourceKind.Custom;
  43. Assert.AreEqual (PaperSourceKind.Custom, ps.Kind, "Kind #8");
  44. Assert.AreEqual (257, ps.RawKind, "RawKind #8");
  45. //
  46. // An integer value of 256 and above returns Custom (0x257)
  47. ps.RawKind = 256;
  48. Assert.AreEqual (256, ps.RawKind, "out: #" + 256);
  49. Assert.AreEqual (PaperSourceKind.Custom, ps.Kind, "kind is custom: #" + 256);
  50. //
  51. // Zero
  52. ps.RawKind = 0;
  53. Assert.AreEqual ((PaperSourceKind)0, ps.Kind, "Kind #1");
  54. Assert.AreEqual (0, ps.RawKind, "RawKind #1");
  55. //
  56. // Well-known
  57. ps.RawKind = (int)PaperSourceKind.Upper;
  58. Assert.AreEqual (PaperSourceKind.Upper, ps.Kind, "Kind #2");
  59. Assert.AreEqual ((int)PaperSourceKind.Upper, ps.RawKind, "RawKind #2");
  60. //
  61. ps.RawKind = (int)PaperSourceKind.FormSource;
  62. Assert.AreEqual (PaperSourceKind.FormSource, ps.Kind, "Kind #3");
  63. Assert.AreEqual ((int)PaperSourceKind.FormSource, ps.RawKind, "RawKind #3");
  64. //
  65. // Too Big
  66. ps.RawKind = 999999;
  67. Assert.AreEqual (PaperSourceKind.Custom, ps.Kind, "Kind #4");
  68. Assert.AreEqual (999999, ps.RawKind, "RawKind #4");
  69. //
  70. ps.RawKind = int.MaxValue;
  71. Assert.AreEqual (PaperSourceKind.Custom, ps.Kind, "Kind #5");
  72. Assert.AreEqual (int.MaxValue, ps.RawKind, "RawKind #5");
  73. //
  74. // Negative -- Looks as if MSFT forgot to check for negative!
  75. ps.RawKind = -1;
  76. Assert.AreEqual ((PaperSourceKind)(-1), ps.Kind, "Kind #6");
  77. Assert.AreEqual (-1, ps.RawKind, "RawKind #6");
  78. //
  79. ps.RawKind = int.MinValue;
  80. Assert.AreEqual ((PaperSourceKind)(int.MinValue), ps.Kind, "Kind #7");
  81. Assert.AreEqual (int.MinValue, ps.RawKind, "RawKind #7");
  82. }
  83. #endif
  84. }
  85. }