XsltExceptionTests.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // XsltExceptionTests.cs - Unit tests for System.Xml.Xsl.XsltException
  3. //
  4. // Author:
  5. // Gert Driesen <[email protected]>
  6. //
  7. // Copyright (C) 2005 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 NUnit.Framework;
  29. using System;
  30. using System.Runtime.Serialization;
  31. using System.Xml.Xsl;
  32. namespace MonoCasTests.System.Xml.Xsl {
  33. [TestFixture]
  34. public class XsltExceptionTests
  35. {
  36. #if NET_2_0
  37. [Test]
  38. public void Constructor0 ()
  39. {
  40. XsltException xsltException = new XsltException ();
  41. Assert.AreEqual (0, xsltException.LineNumber, "#1");
  42. Assert.AreEqual (0, xsltException.LinePosition, "#2");
  43. Assert.AreEqual (string.Empty, xsltException.Message, "#3");
  44. Assert.IsNull (xsltException.SourceUri, "#4");
  45. Assert.IsNull (xsltException.InnerException, "#5");
  46. Assert.IsNull (xsltException.Source, "#6");
  47. Assert.IsNull (xsltException.StackTrace, "#7");
  48. Assert.IsNull (xsltException.TargetSite, "#8");
  49. }
  50. [Test]
  51. public void Constructor1 ()
  52. {
  53. string msg = "mono";
  54. XsltException xsltException = new XsltException (msg);
  55. Assert.AreEqual (0, xsltException.LineNumber, "#1");
  56. Assert.AreEqual (0, xsltException.LinePosition, "#2");
  57. Assert.AreEqual (msg, xsltException.Message, "#3");
  58. Assert.IsNull (xsltException.SourceUri, "#4");
  59. Assert.IsNull (xsltException.InnerException, "#5");
  60. Assert.IsNull (xsltException.Source, "#6");
  61. Assert.IsNull (xsltException.StackTrace, "#7");
  62. Assert.IsNull (xsltException.TargetSite, "#8");
  63. }
  64. #endif
  65. [Test]
  66. public void Constructor2 ()
  67. {
  68. string msg = "mono";
  69. Exception cause = new ApplicationException ("cause");
  70. XsltException xsltException = new XsltException (msg, cause);
  71. Assert.AreEqual (0, xsltException.LineNumber, "#A1");
  72. Assert.AreEqual (0, xsltException.LinePosition, "#A2");
  73. Assert.AreEqual (msg, xsltException.Message, "#A3");
  74. Assert.IsNull (xsltException.SourceUri, "#A4");
  75. Assert.AreSame (cause, xsltException.InnerException, "#A5");
  76. Assert.IsNull (xsltException.Source, "#A6");
  77. Assert.IsNull (xsltException.StackTrace, "#A7");
  78. Assert.IsNull (xsltException.TargetSite, "#A8");
  79. xsltException = new XsltException ((string) null, cause);
  80. Assert.AreEqual (0, xsltException.LineNumber, "#B1");
  81. Assert.AreEqual (0, xsltException.LinePosition, "#B2");
  82. Assert.IsNotNull (xsltException.Message, "#B3");
  83. Assert.AreEqual (string.Empty, xsltException.Message, "#B4");
  84. Assert.IsNull (xsltException.SourceUri, "#B5");
  85. Assert.AreSame (cause, xsltException.InnerException, "#B6");
  86. Assert.IsNull (xsltException.Source, "#B7");
  87. Assert.IsNull (xsltException.StackTrace, "#B8");
  88. Assert.IsNull (xsltException.TargetSite, "#B9");
  89. xsltException = new XsltException (msg, (Exception) null);
  90. Assert.AreEqual (0, xsltException.LineNumber, "#C1");
  91. Assert.AreEqual (0, xsltException.LinePosition, "#C2");
  92. Assert.AreEqual (msg, xsltException.Message, "#C3");
  93. Assert.IsNull (xsltException.SourceUri, "#C4");
  94. Assert.IsNull (xsltException.InnerException, "#C5");
  95. Assert.IsNull (xsltException.Source, "#C6");
  96. Assert.IsNull (xsltException.StackTrace, "#C7");
  97. Assert.IsNull (xsltException.TargetSite, "#C8");
  98. xsltException = new XsltException ((string) null, (Exception) null);
  99. Assert.AreEqual (0, xsltException.LineNumber, "#D1");
  100. Assert.AreEqual (0, xsltException.LinePosition, "#D2");
  101. Assert.AreEqual (string.Empty, xsltException.Message, "#D3");
  102. Assert.IsNull (xsltException.SourceUri, "#D4");
  103. Assert.IsNull (xsltException.InnerException, "#D5");
  104. Assert.IsNull (xsltException.Source, "#D6");
  105. Assert.IsNull (xsltException.StackTrace, "#D7");
  106. Assert.IsNull (xsltException.TargetSite, "#D8");
  107. }
  108. }
  109. }