PrintDialogTest.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 ("NotWorking")]
  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. public void DocumentTest ()
  55. {
  56. PrintDialog pd = new PrintDialog ();
  57. PrintDocument pdoc1 = new PrintDocument ();
  58. PrinterSettings ps1 = new PrinterSettings ();
  59. pdoc1.PrinterSettings = ps1;
  60. pd.Document = pdoc1;
  61. Assert.AreEqual (pdoc1, pd.Document, "#1");
  62. Assert.AreEqual (ps1, pd.PrinterSettings, "#2");
  63. PrinterSettings ps2 = new PrinterSettings ();
  64. pdoc1.PrinterSettings = ps2;
  65. pd.Document = pdoc1;
  66. Assert.AreEqual (pdoc1, pd.Document, "#3");
  67. Assert.AreEqual (ps2, pd.PrinterSettings, "#4");
  68. pd.Document = null;
  69. Assert.IsNull (pd.Document, "#5");
  70. Assert.IsNotNull (pd.PrinterSettings, "#6");
  71. if (pd.PrinterSettings == ps1)
  72. Assert.Fail ("#7");
  73. }
  74. [Test]
  75. public void PrinterSettingsTest ()
  76. {
  77. PrintDialog pd = new PrintDialog ();
  78. PrinterSettings ps1 = new PrinterSettings ();
  79. pd.PrinterSettings = ps1;
  80. Assert.AreEqual (ps1, pd.PrinterSettings, "#1");
  81. Assert.IsNull (pd.Document, "#2");
  82. pd.PrinterSettings = null;
  83. Assert.IsNotNull (pd.PrinterSettings, "#3");
  84. Assert.IsNull (pd.Document, "#4");
  85. if (pd.PrinterSettings == ps1)
  86. Assert.Fail ("#5");
  87. }
  88. }
  89. }