XsltExceptionTests.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. #if !TARGET_JVM
  48. Assert.IsNull (xsltException.StackTrace, "#7");
  49. Assert.IsNull (xsltException.TargetSite, "#8");
  50. #endif
  51. }
  52. [Test]
  53. public void Constructor1 ()
  54. {
  55. string msg = "mono";
  56. XsltException xsltException = new XsltException (msg);
  57. Assert.AreEqual (0, xsltException.LineNumber, "#1");
  58. Assert.AreEqual (0, xsltException.LinePosition, "#2");
  59. Assert.AreEqual (msg, xsltException.Message, "#3");
  60. Assert.IsNull (xsltException.SourceUri, "#4");
  61. Assert.IsNull (xsltException.InnerException, "#5");
  62. Assert.IsNull (xsltException.Source, "#6");
  63. #if !TARGET_JVM
  64. Assert.IsNull (xsltException.StackTrace, "#7");
  65. Assert.IsNull (xsltException.TargetSite, "#8");
  66. #endif
  67. }
  68. #endif
  69. [Test]
  70. public void Constructor2 ()
  71. {
  72. string msg = "mono";
  73. Exception cause = new ApplicationException ("cause");
  74. XsltException xsltException = new XsltException (msg, cause);
  75. Assert.AreEqual (0, xsltException.LineNumber, "#A1");
  76. Assert.AreEqual (0, xsltException.LinePosition, "#A2");
  77. Assert.AreEqual (msg, xsltException.Message, "#A3");
  78. Assert.IsNull (xsltException.SourceUri, "#A4");
  79. Assert.AreSame (cause, xsltException.InnerException, "#A5");
  80. Assert.IsNull (xsltException.Source, "#A6");
  81. #if !TARGET_JVM
  82. Assert.IsNull (xsltException.StackTrace, "#A7");
  83. Assert.IsNull (xsltException.TargetSite, "#A8");
  84. #endif
  85. xsltException = new XsltException ((string) null, cause);
  86. Assert.AreEqual (0, xsltException.LineNumber, "#B1");
  87. Assert.AreEqual (0, xsltException.LinePosition, "#B2");
  88. Assert.IsNotNull (xsltException.Message, "#B3");
  89. Assert.AreEqual (string.Empty, xsltException.Message, "#B4");
  90. Assert.IsNull (xsltException.SourceUri, "#B5");
  91. Assert.AreSame (cause, xsltException.InnerException, "#B6");
  92. Assert.IsNull (xsltException.Source, "#B7");
  93. #if !TARGET_JVM
  94. Assert.IsNull (xsltException.StackTrace, "#B8");
  95. Assert.IsNull (xsltException.TargetSite, "#B9");
  96. #endif
  97. xsltException = new XsltException (msg, (Exception) null);
  98. Assert.AreEqual (0, xsltException.LineNumber, "#C1");
  99. Assert.AreEqual (0, xsltException.LinePosition, "#C2");
  100. Assert.AreEqual (msg, xsltException.Message, "#C3");
  101. Assert.IsNull (xsltException.SourceUri, "#C4");
  102. Assert.IsNull (xsltException.InnerException, "#C5");
  103. Assert.IsNull (xsltException.Source, "#C6");
  104. #if !TARGET_JVM
  105. Assert.IsNull (xsltException.StackTrace, "#C7");
  106. Assert.IsNull (xsltException.TargetSite, "#C8");
  107. #endif
  108. xsltException = new XsltException ((string) null, (Exception) null);
  109. Assert.AreEqual (0, xsltException.LineNumber, "#D1");
  110. Assert.AreEqual (0, xsltException.LinePosition, "#D2");
  111. Assert.AreEqual (string.Empty, xsltException.Message, "#D3");
  112. Assert.IsNull (xsltException.SourceUri, "#D4");
  113. Assert.IsNull (xsltException.InnerException, "#D5");
  114. Assert.IsNull (xsltException.Source, "#D6");
  115. #if !TARGET_JVM
  116. Assert.IsNull (xsltException.StackTrace, "#D7");
  117. Assert.IsNull (xsltException.TargetSite, "#D8");
  118. #endif
  119. }
  120. }
  121. }