PrintDialogTest.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // PrintDialogTest.cs: Tests for PrintDialog class.
  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. // Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
  24. //
  25. // Authors:
  26. // Carlos Alberto Cortez <[email protected]>
  27. //
  28. using System;
  29. using System.Collections;
  30. using System.Drawing;
  31. using System.Drawing.Printing;
  32. using System.Windows.Forms;
  33. using NUnit.Framework;
  34. namespace MonoTests.System.Windows.Forms
  35. {
  36. [TestFixture]
  37. public class PrintDialogTest
  38. {
  39. [Test]
  40. [Category("Printing")]
  41. public void DefaultValues ()
  42. {
  43. PrintDialog pd = new PrintDialog ();
  44. Assert.IsTrue (pd.AllowPrintToFile, "#1");
  45. Assert.IsFalse (pd.AllowSelection, "#2");
  46. Assert.IsFalse (pd.AllowSomePages, "#3");
  47. Assert.IsNull (pd.Document, "#4");
  48. Assert.IsNull (pd.PrinterSettings, "#5");
  49. Assert.IsFalse (pd.PrintToFile, "#6");
  50. Assert.IsFalse (pd.ShowHelp, "#7");
  51. Assert.IsTrue (pd.ShowNetwork, "#8");
  52. }
  53. [Test]
  54. [Category("Printing")]
  55. public void DocumentTest ()
  56. {
  57. PrintDialog pd = new PrintDialog ();
  58. PrintDocument pdoc1 = new PrintDocument ();
  59. PrinterSettings ps1 = new PrinterSettings ();
  60. pdoc1.PrinterSettings = ps1;
  61. pd.Document = pdoc1;
  62. Assert.AreEqual (pdoc1, pd.Document, "#1");
  63. Assert.AreEqual (ps1, pd.PrinterSettings, "#2");
  64. PrinterSettings ps2 = new PrinterSettings ();
  65. pdoc1.PrinterSettings = ps2;
  66. pd.Document = pdoc1;
  67. Assert.AreEqual (pdoc1, pd.Document, "#3");
  68. Assert.AreEqual (ps2, pd.PrinterSettings, "#4");
  69. pd.Document = null;
  70. Assert.IsNull (pd.Document, "#5");
  71. Assert.IsNotNull (pd.PrinterSettings, "#6");
  72. if (pd.PrinterSettings == ps1)
  73. Assert.Fail ("#7");
  74. }
  75. [Test]
  76. [Category("Printing")]
  77. public void PrinterSettingsTest ()
  78. {
  79. PrintDialog pd = new PrintDialog ();
  80. PrinterSettings ps1 = new PrinterSettings ();
  81. pd.PrinterSettings = ps1;
  82. Assert.AreEqual (ps1, pd.PrinterSettings, "#1");
  83. Assert.IsNull (pd.Document, "#2");
  84. pd.PrinterSettings = null;
  85. Assert.IsNotNull (pd.PrinterSettings, "#3");
  86. Assert.IsNull (pd.Document, "#4");
  87. if (pd.PrinterSettings == ps1)
  88. Assert.Fail ("#5");
  89. }
  90. }
  91. }