CheckoutExceptionTest.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //
  2. // CheckoutExceptionTest.cs - NUnit tests for CheckoutException
  3. //
  4. // Author:
  5. // Gert Driesen <[email protected]>
  6. //
  7. // Copyright (C) 2007 Gert Driesen
  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 System;
  29. using System.ComponentModel.Design;
  30. using System.Runtime.InteropServices;
  31. using NUnit.Framework;
  32. namespace MonoTests.System.ComponentModel.Design
  33. {
  34. [TestFixture]
  35. public class CheckoutExceptionTest
  36. {
  37. [Test] // ctor ()
  38. public void Constructor0 ()
  39. {
  40. CheckoutException ex = new CheckoutException ();
  41. Assert.AreEqual (-2147467259, ex.ErrorCode, "#1");
  42. Assert.IsNull (ex.InnerException, "#2");
  43. Assert.IsNotNull (ex.Message, "#3");
  44. Assert.IsTrue (ex.Message.IndexOf (ex.GetType ().FullName) == -1, "#4");
  45. Assert.AreEqual (new ExternalException ().Message, ex.Message, "#5");
  46. }
  47. [Test] // ctor (string)
  48. public void Constructor1 ()
  49. {
  50. CheckoutException ex;
  51. string msg = "ERROR";
  52. ex = new CheckoutException (msg);
  53. Assert.AreEqual (-2147467259, ex.ErrorCode, "#A1");
  54. Assert.IsNull (ex.InnerException, "#A2");
  55. Assert.AreSame (msg, ex.Message, "#A3");
  56. ex = new CheckoutException ((string) null);
  57. Assert.AreEqual (-2147467259, ex.ErrorCode, "#B1");
  58. Assert.IsNull (ex.InnerException, "#B2");
  59. Assert.IsNotNull (msg, ex.Message, "#B3");
  60. Assert.IsTrue (ex.Message.IndexOf (ex.GetType ().FullName) != -1, "#B4");
  61. ex = new CheckoutException (string.Empty);
  62. Assert.AreEqual (-2147467259, ex.ErrorCode, "#C1");
  63. Assert.IsNull (ex.InnerException, "#C2");
  64. Assert.IsNotNull (msg, ex.Message, "#C3");
  65. Assert.AreEqual (string.Empty, ex.Message, "#C4");
  66. }
  67. #if NET_2_0
  68. [Test] // ctor (string, Exception)
  69. public void Constructor3 ()
  70. {
  71. CheckoutException ex;
  72. string msg = "ERROR";
  73. Exception inner = new Exception ();
  74. ex = new CheckoutException (msg, inner);
  75. Assert.AreEqual (-2147467259, ex.ErrorCode, "#A1");
  76. Assert.AreSame (inner, ex.InnerException, "#A2");
  77. Assert.AreSame (msg, ex.Message, "#A3");
  78. ex = new CheckoutException ((string) null, inner);
  79. Assert.AreEqual (-2147467259, ex.ErrorCode, "#B1");
  80. Assert.AreSame (inner, ex.InnerException, "#B2");
  81. Assert.IsNotNull (msg, ex.Message, "#B3");
  82. Assert.AreEqual (new CheckoutException (null).Message, ex.Message, "#B4");
  83. ex = new CheckoutException (msg, (Exception) null);
  84. Assert.AreEqual (-2147467259, ex.ErrorCode, "#C1");
  85. Assert.IsNull (ex.InnerException, "#C2");
  86. Assert.AreSame (msg, ex.Message, "#C3");
  87. ex = new CheckoutException (string.Empty, (Exception) null);
  88. Assert.AreEqual (-2147467259, ex.ErrorCode, "#D1");
  89. Assert.IsNull (ex.InnerException, "#D2");
  90. Assert.IsNotNull (ex.Message, "#D3");
  91. Assert.AreEqual (string.Empty, ex.Message, "#D4");
  92. }
  93. #endif
  94. [Test] // ctor (string, int)
  95. public void Constructor4 ()
  96. {
  97. CheckoutException ex;
  98. string msg = "ERROR";
  99. ex = new CheckoutException (msg, int.MinValue);
  100. Assert.AreEqual (int.MinValue, ex.ErrorCode, "#A1");
  101. Assert.IsNull (ex.InnerException, "#A2");
  102. Assert.AreSame (msg, ex.Message, "#A3");
  103. ex = new CheckoutException ((string) null, int.MaxValue);
  104. Assert.AreEqual (int.MaxValue, ex.ErrorCode, "#B1");
  105. Assert.IsNull (ex.InnerException, "#B2");
  106. Assert.IsNotNull (msg, ex.Message, "#B3");
  107. Assert.AreEqual (new CheckoutException (null).Message, ex.Message, "#B4");
  108. ex = new CheckoutException (msg, 0);
  109. Assert.AreEqual (0, ex.ErrorCode, "#C1");
  110. Assert.IsNull (ex.InnerException, "#C2");
  111. Assert.AreSame (msg, ex.Message, "#C3");
  112. ex = new CheckoutException (string.Empty, 0);
  113. Assert.AreEqual (0, ex.ErrorCode, "#D1");
  114. Assert.IsNull (ex.InnerException, "#D2");
  115. Assert.IsNotNull (ex.Message, "#D3");
  116. Assert.AreEqual (string.Empty, ex.Message, "#D4");
  117. }
  118. [Test]
  119. public void Canceled ()
  120. {
  121. CheckoutException ex = CheckoutException.Canceled;
  122. #if NET_2_0
  123. Assert.AreEqual (-2147467260, ex.ErrorCode, "#1");
  124. #else
  125. Assert.AreEqual (-2147467259, ex.ErrorCode, "#1");
  126. #endif
  127. Assert.IsNull (ex.InnerException, "#2");
  128. Assert.IsNotNull (ex.Message, "#3");
  129. Assert.IsTrue (ex.Message.IndexOf (ex.GetType ().FullName) == -1, "#4");
  130. }
  131. }
  132. }