PrintDialogTest.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. public void DefaultValues ()
  41. {
  42. PrintDialog pd = new PrintDialog ();
  43. Assert.IsTrue (pd.AllowPrintToFile, "#1");
  44. Assert.IsFalse (pd.AllowSelection, "#2");
  45. Assert.IsFalse (pd.AllowSomePages, "#3");
  46. Assert.IsNull (pd.Document, "#4");
  47. Assert.IsNull (pd.PrinterSettings, "#5");
  48. Assert.IsFalse (pd.PrintToFile, "#6");
  49. Assert.IsFalse (pd.ShowHelp, "#7");
  50. Assert.IsTrue (pd.ShowNetwork, "#8");
  51. }
  52. [Test]
  53. public void DocumentTest ()
  54. {
  55. PrintDialog pd = new PrintDialog ();
  56. PrintDocument pdoc1 = new PrintDocument ();
  57. PrinterSettings ps1 = new PrinterSettings ();
  58. pdoc1.PrinterSettings = ps1;
  59. pd.Document = pdoc1;
  60. Assert.AreEqual (pdoc1, pd.Document, "#1");
  61. Assert.AreEqual (ps1, pd.PrinterSettings, "#2");
  62. PrinterSettings ps2 = new PrinterSettings ();
  63. pdoc1.PrinterSettings = ps2;
  64. pd.Document = pdoc1;
  65. Assert.AreEqual (pdoc1, pd.Document, "#3");
  66. Assert.AreEqual (ps2, pd.PrinterSettings, "#4");
  67. pd.Document = null;
  68. Assert.IsNull (pd.Document, "#5");
  69. Assert.IsNotNull (pd.PrinterSettings, "#6");
  70. if (pd.PrinterSettings == ps1)
  71. Assert.Fail ("#7");
  72. }
  73. [Test]
  74. public void PrinterSettingsTest ()
  75. {
  76. PrintDialog pd = new PrintDialog ();
  77. PrinterSettings ps1 = new PrinterSettings ();
  78. pd.PrinterSettings = ps1;
  79. Assert.AreEqual (ps1, pd.PrinterSettings, "#1");
  80. Assert.IsNull (pd.Document, "#2");
  81. pd.PrinterSettings = null;
  82. Assert.IsNotNull (pd.PrinterSettings, "#3");
  83. Assert.IsNull (pd.Document, "#4");
  84. if (pd.PrinterSettings == ps1)
  85. Assert.Fail ("#5");
  86. }
  87. }
  88. }