WmfPlaceableFileHeaderTest.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // WmfPlaceableFileHeader class testing unit
  3. //
  4. // Authors:
  5. // Sebastien Pouliot <[email protected]>
  6. //
  7. // Copyright (C) 2006 Novell, Inc (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. using System.Drawing;
  30. using System.Drawing.Imaging;
  31. using System.Security.Permissions;
  32. using NUnit.Framework;
  33. namespace MonoTests.System.Drawing.Imaging {
  34. [TestFixture]
  35. [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
  36. public class WmfPlaceableFileHeaderTest {
  37. [Test]
  38. public void DefaultValues ()
  39. {
  40. WmfPlaceableFileHeader wh = new WmfPlaceableFileHeader ();
  41. Assert.AreEqual (0, wh.BboxBottom, "BboxBottom");
  42. Assert.AreEqual (0, wh.BboxLeft, "BboxLeft");
  43. Assert.AreEqual (0, wh.BboxRight, "BboxRight");
  44. Assert.AreEqual (0, wh.BboxTop, "BboxTop");
  45. Assert.AreEqual (0, wh.Checksum, "Checksum");
  46. Assert.AreEqual (0, wh.Hmf, "Hmf");
  47. Assert.AreEqual (0, wh.Inch, "Inch");
  48. Assert.AreEqual (unchecked ((int)0x9AC6CDD7), wh.Key, "Key"); // always (from documentation)
  49. Assert.AreEqual (0, wh.Reserved, "Reserved");
  50. }
  51. [Test]
  52. public void Min ()
  53. {
  54. WmfPlaceableFileHeader wh = new WmfPlaceableFileHeader ();
  55. wh.BboxBottom = short.MinValue;
  56. Assert.AreEqual (short.MinValue, wh.BboxBottom, "BboxBottom");
  57. wh.BboxLeft = short.MinValue;
  58. Assert.AreEqual (short.MinValue, wh.BboxLeft, "BboxLeft");
  59. wh.BboxRight = short.MinValue;
  60. Assert.AreEqual (short.MinValue, wh.BboxRight, "BboxRight");
  61. wh.BboxTop = short.MinValue;
  62. Assert.AreEqual (short.MinValue, wh.BboxTop, "BboxTop");
  63. wh.Checksum = short.MinValue;
  64. Assert.AreEqual (short.MinValue, wh.Checksum, "Checksum");
  65. wh.Hmf = short.MinValue;
  66. Assert.AreEqual (short.MinValue, wh.Hmf, "Hmf");
  67. wh.Inch = short.MinValue;
  68. Assert.AreEqual (short.MinValue, wh.Inch, "Inch");
  69. wh.Key = int.MinValue;
  70. Assert.AreEqual (int.MinValue, wh.Key, "Key");
  71. wh.Reserved = int.MinValue;
  72. Assert.AreEqual (int.MinValue, wh.Reserved, "Reserved");
  73. }
  74. [Test]
  75. public void Max ()
  76. {
  77. WmfPlaceableFileHeader wh = new WmfPlaceableFileHeader ();
  78. wh.BboxBottom = short.MaxValue;
  79. Assert.AreEqual (short.MaxValue, wh.BboxBottom, "BboxBottom");
  80. wh.BboxLeft = short.MaxValue;
  81. Assert.AreEqual (short.MaxValue, wh.BboxLeft, "BboxLeft");
  82. wh.BboxRight = short.MaxValue;
  83. Assert.AreEqual (short.MaxValue, wh.BboxRight, "BboxRight");
  84. wh.BboxTop = short.MaxValue;
  85. Assert.AreEqual (short.MaxValue, wh.BboxTop, "BboxTop");
  86. wh.Checksum = short.MaxValue;
  87. Assert.AreEqual (short.MaxValue, wh.Checksum, "Checksum");
  88. wh.Hmf = short.MaxValue;
  89. Assert.AreEqual (short.MaxValue, wh.Hmf, "Hmf");
  90. wh.Inch = short.MaxValue;
  91. Assert.AreEqual (short.MaxValue, wh.Inch, "Inch");
  92. wh.Key = int.MaxValue;
  93. Assert.AreEqual (int.MaxValue, wh.Key, "Key");
  94. wh.Reserved = int.MaxValue;
  95. Assert.AreEqual (int.MaxValue, wh.Reserved, "Reserved");
  96. }
  97. }
  98. }