CodeGotoStatementTest.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //
  2. // CodeGotoStatementTest.cs
  3. // - Unit tests for System.CodeDom.CodeGotoStatement
  4. //
  5. // Author:
  6. // Gert Driesen <[email protected]>
  7. //
  8. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using NUnit.Framework;
  30. using System;
  31. using System.CodeDom;
  32. using System.Collections.Specialized;
  33. namespace MonoTests.System.CodeDom
  34. {
  35. [TestFixture]
  36. public class CodeGotoStatementTest
  37. {
  38. #if NET_2_0
  39. [Test]
  40. public void Constructor0 ()
  41. {
  42. CodeGotoStatement cgs = new CodeGotoStatement ();
  43. Assert.IsNull (cgs.Label, "#1");
  44. Assert.IsNotNull (cgs.StartDirectives, "#2");
  45. Assert.AreEqual (0, cgs.StartDirectives.Count, "#3");
  46. Assert.IsNotNull (cgs.EndDirectives, "#4");
  47. Assert.AreEqual (0, cgs.EndDirectives.Count, "#5");
  48. Assert.IsNotNull (cgs.UserData, "#6");
  49. Assert.AreEqual (typeof(ListDictionary), cgs.UserData.GetType (), "#7");
  50. Assert.AreEqual (0, cgs.UserData.Count, "#8");
  51. Assert.IsNull (cgs.LinePragma, "#9");
  52. CodeLinePragma clp = new CodeLinePragma ("mono", 10);
  53. cgs.LinePragma = clp;
  54. Assert.IsNotNull (cgs.LinePragma, "#10");
  55. Assert.AreSame (clp, cgs.LinePragma, "#11");
  56. cgs.LinePragma = null;
  57. Assert.IsNull (cgs.LinePragma, "#12");
  58. string label = "mono";
  59. cgs.Label = label;
  60. Assert.AreSame (label, cgs.Label, "#13");
  61. }
  62. #endif
  63. [Test]
  64. public void Constructor1 ()
  65. {
  66. string label1 = "mono1";
  67. CodeGotoStatement cgs = new CodeGotoStatement (label1);
  68. Assert.IsNotNull (cgs.Label, "#1");
  69. Assert.AreSame (label1, cgs.Label, "#2");
  70. #if NET_2_0
  71. Assert.IsNotNull (cgs.StartDirectives, "#3");
  72. Assert.AreEqual (0, cgs.StartDirectives.Count, "#4");
  73. Assert.IsNotNull (cgs.EndDirectives, "#5");
  74. Assert.AreEqual (0, cgs.EndDirectives.Count, "#6");
  75. #endif
  76. Assert.IsNotNull (cgs.UserData, "#7");
  77. Assert.AreEqual (typeof(ListDictionary), cgs.UserData.GetType (), "#8");
  78. Assert.AreEqual (0, cgs.UserData.Count, "#9");
  79. Assert.IsNull (cgs.LinePragma, "#10");
  80. string label2 = "mono2";
  81. cgs.Label = label2;
  82. Assert.AreSame (label2, cgs.Label, "#11");
  83. }
  84. [Test]
  85. #if NET_2_0
  86. [ExpectedException (typeof (ArgumentNullException))]
  87. #endif
  88. public void Constructor1_NullLabel ()
  89. {
  90. CodeGotoStatement cgs = new CodeGotoStatement ((string) null);
  91. #if ONLY_1_1
  92. Assert.IsNull (cgs.Label, "#1");
  93. #endif
  94. }
  95. [Test]
  96. #if NET_2_0
  97. [ExpectedException (typeof (ArgumentNullException))]
  98. #endif
  99. public void Constructor1_EmptyLabel () {
  100. CodeGotoStatement cgs = new CodeGotoStatement (string.Empty);
  101. #if ONLY_1_1
  102. Assert.IsNotNull (cgs.Label, "#1");
  103. Assert.AreEqual (string.Empty, cgs.Label, "#2");
  104. #endif
  105. }
  106. [Test]
  107. #if NET_2_0
  108. [ExpectedException (typeof (ArgumentNullException))]
  109. #endif
  110. public void Label_Null ()
  111. {
  112. CodeGotoStatement cgs = new CodeGotoStatement ("mono");
  113. cgs.Label = null;
  114. #if ONLY_1_1
  115. Assert.IsNull (cgs.Label, "#1");
  116. #endif
  117. }
  118. [Test]
  119. #if NET_2_0
  120. [ExpectedException (typeof (ArgumentNullException))]
  121. #endif
  122. public void Label_Empty () {
  123. CodeGotoStatement cgs = new CodeGotoStatement ("mono");
  124. cgs.Label = string.Empty;
  125. #if ONLY_1_1
  126. Assert.IsNotNull (cgs.Label, "#1");
  127. Assert.AreEqual (string.Empty, cgs.Label, "#2");
  128. #endif
  129. }
  130. }
  131. }