CodeGeneratorOptionsTest.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // CodeGeneratorOptionsTest.cs
  3. // - Unit tests for System.CodeDom.Compiler.CodeGeneratorOptions
  4. //
  5. // Author:
  6. // Sebastien Pouliot <[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.Compiler;
  32. namespace MonoTests.System.CodeDom.Compiler {
  33. [TestFixture]
  34. public class CodeGeneratorOptionsTest {
  35. [Test]
  36. public void Defaults ()
  37. {
  38. CodeGeneratorOptions cgo = new CodeGeneratorOptions ();
  39. Assert.IsTrue (cgo.BlankLinesBetweenMembers, "BlankLinesBetweenMembers");
  40. Assert.AreEqual ("Block", cgo.BracingStyle, "BracingStyle");
  41. Assert.IsFalse (cgo.ElseOnClosing, "ElseOnClosing");
  42. Assert.AreEqual (" ", cgo.IndentString, "IndentString");
  43. #if NET_2_0
  44. Assert.IsFalse (cgo.VerbatimOrder, "VerbatimOrder");
  45. #endif
  46. Assert.IsNull (cgo["BlankLinesBetweenMembers"], "this[BlankLinesBetweenMembers]");
  47. Assert.IsNull (cgo["BracingStyle"], "this[BracingStyle]");
  48. Assert.IsNull (cgo["ElseOnClosing"], "this[ElseOnClosing]");
  49. Assert.IsNull (cgo["IndentString"], "this[IndentString]");
  50. #if NET_2_0
  51. Assert.IsNull (cgo["VerbatimOrder"], "this[VerbatimOrder]");
  52. #endif
  53. }
  54. [Test]
  55. public void ReSetDefault ()
  56. {
  57. CodeGeneratorOptions cgo = new CodeGeneratorOptions ();
  58. cgo.BlankLinesBetweenMembers = cgo.BlankLinesBetweenMembers;
  59. Assert.IsNotNull (cgo["BlankLinesBetweenMembers"], "this[BlankLinesBetweenMembers]");
  60. cgo.BracingStyle = cgo.BracingStyle;
  61. Assert.IsNotNull (cgo["BracingStyle"], "this[BracingStyle]");
  62. cgo.ElseOnClosing = cgo.ElseOnClosing;
  63. Assert.IsNotNull (cgo["ElseOnClosing"], "this[ElseOnClosing]");
  64. cgo.IndentString = cgo.IndentString;
  65. Assert.IsNotNull (cgo["IndentString"], "this[IndentString]");
  66. #if NET_2_0
  67. cgo.VerbatimOrder = cgo.VerbatimOrder;
  68. Assert.IsNotNull (cgo["VerbatimOrder"], "this[VerbatimOrder]");
  69. #endif
  70. }
  71. [Test]
  72. public void Nullify ()
  73. {
  74. CodeGeneratorOptions cgo = new CodeGeneratorOptions ();
  75. cgo.BlankLinesBetweenMembers = false;
  76. Assert.IsFalse (cgo.BlankLinesBetweenMembers, "BlankLinesBetweenMembers-1");
  77. cgo["BlankLinesBetweenMembers"] = null;
  78. Assert.IsTrue (cgo.BlankLinesBetweenMembers, "BlankLinesBetweenMembers-2");
  79. cgo.BracingStyle = "C";
  80. Assert.AreEqual ("C", cgo.BracingStyle, "BracingStyle-1");
  81. cgo["BracingStyle"] = null;
  82. Assert.AreEqual ("Block", cgo.BracingStyle, "BracingStyle-2");
  83. cgo.ElseOnClosing = true;
  84. Assert.IsTrue (cgo.ElseOnClosing, "ElseOnClosing-1");
  85. cgo["ElseOnClosing"] = null;
  86. Assert.IsFalse (cgo.ElseOnClosing, "ElseOnClosing-2");
  87. cgo.IndentString = "\t";
  88. Assert.AreEqual ("\t", cgo.IndentString, "IndentString-1");
  89. cgo["IndentString"] = null;
  90. Assert.AreEqual (" ", cgo.IndentString, "IndentString-2");
  91. #if NET_2_0
  92. cgo.VerbatimOrder = true;
  93. Assert.IsTrue (cgo.VerbatimOrder, "VerbatimOrder-1");
  94. cgo["VerbatimOrder"] = null;
  95. Assert.IsFalse (cgo.VerbatimOrder, "VerbatimOrder-2");
  96. #endif
  97. }
  98. }
  99. }