CodeLabeledStatementTest.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //
  2. // CodeLabeledStatementTest.cs
  3. // - Unit tests for System.CodeDom.CodeLabeledStatement
  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 CodeLabeledStatementTest
  37. {
  38. [Test]
  39. public void Constructor0 ()
  40. {
  41. CodeLabeledStatement cls = new CodeLabeledStatement ();
  42. Assert.IsNull (cls.LinePragma, "#1");
  43. Assert.IsNotNull (cls.Label, "#2");
  44. Assert.AreEqual (string.Empty, cls.Label, "#3");
  45. #if NET_2_0
  46. Assert.IsNotNull (cls.StartDirectives, "#4");
  47. Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
  48. Assert.IsNotNull (cls.EndDirectives, "#6");
  49. Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
  50. #endif
  51. Assert.IsNotNull (cls.UserData, "#8");
  52. Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
  53. Assert.AreEqual (0, cls.UserData.Count, "#10");
  54. string label = "mono";
  55. cls.Label = label;
  56. Assert.IsNotNull (cls.Label, "#11");
  57. Assert.AreSame (label, cls.Label, "#12");
  58. cls.Label = null;
  59. Assert.IsNotNull (cls.Label, "#13");
  60. Assert.AreEqual (string.Empty, cls.Label, "#14");
  61. CodeLinePragma clp = new CodeLinePragma ("mono", 10);
  62. cls.LinePragma = clp;
  63. Assert.IsNotNull (cls.LinePragma, "#15");
  64. Assert.AreSame (clp, cls.LinePragma, "#16");
  65. cls.LinePragma = null;
  66. Assert.IsNull (cls.LinePragma, "#17");
  67. Assert.IsNull (cls.Statement, "#18");
  68. CodeStatement stmt = new CodeStatement ();
  69. cls.Statement = stmt;
  70. Assert.IsNotNull (cls.Statement, "#19");
  71. Assert.AreSame (stmt, cls.Statement);
  72. }
  73. [Test]
  74. public void Constructor1 ()
  75. {
  76. string label = "mono";
  77. CodeLabeledStatement cls = new CodeLabeledStatement (label);
  78. Assert.IsNull (cls.LinePragma, "#1");
  79. Assert.IsNotNull (cls.Label, "#2");
  80. Assert.AreSame (label, cls.Label, "#3");
  81. #if NET_2_0
  82. Assert.IsNotNull (cls.StartDirectives, "#4");
  83. Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
  84. Assert.IsNotNull (cls.EndDirectives, "#6");
  85. Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
  86. #endif
  87. Assert.IsNotNull (cls.UserData, "#8");
  88. Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
  89. Assert.AreEqual (0, cls.UserData.Count, "#10");
  90. Assert.IsNull (cls.Statement, "#11");
  91. cls = new CodeLabeledStatement ((string) null);
  92. Assert.IsNotNull (cls.Label, "#12");
  93. Assert.AreEqual (string.Empty, cls.Label, "#13");
  94. }
  95. [Test]
  96. public void Constructor2 () {
  97. string label = "mono";
  98. CodeStatement stmt = new CodeStatement ();
  99. CodeLabeledStatement cls = new CodeLabeledStatement (label, stmt);
  100. Assert.IsNull (cls.LinePragma, "#1");
  101. Assert.IsNotNull (cls.Label, "#2");
  102. Assert.AreSame (label, cls.Label, "#3");
  103. #if NET_2_0
  104. Assert.IsNotNull (cls.StartDirectives, "#4");
  105. Assert.AreEqual (0, cls.StartDirectives.Count, "#5");
  106. Assert.IsNotNull (cls.EndDirectives, "#6");
  107. Assert.AreEqual (0, cls.EndDirectives.Count, "#7");
  108. #endif
  109. Assert.IsNotNull (cls.UserData, "#8");
  110. Assert.AreEqual (typeof(ListDictionary), cls.UserData.GetType (), "#9");
  111. Assert.AreEqual (0, cls.UserData.Count, "#10");
  112. Assert.IsNotNull (cls.Statement, "#11");
  113. Assert.AreSame (stmt, cls.Statement, "#12");
  114. cls = new CodeLabeledStatement ((string) null, (CodeStatement) null);
  115. Assert.IsNotNull (cls.Label, "#13");
  116. Assert.AreEqual (string.Empty, cls.Label, "#14");
  117. Assert.IsNull (cls.Statement, "#15");
  118. }
  119. }
  120. }