using System;
using System.CodeDom;
using System.CodeDom.Compiler;
+using System.Globalization;
using System.IO;
using System.Text;
codeNamespace.Comments.Add (comment);
Assert.AreEqual ("// a\n\n", Generate ());
}
+
+ [Test]
+ public void ImportsTest ()
+ {
+ codeNamespace.Imports.Add (new CodeNamespaceImport ("System"));
+ codeNamespace.Imports.Add (new CodeNamespaceImport ("System.Collections"));
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "using System;{0}" +
+ "using System.Collections;{0}" +
+ "{0}", NewLine), Generate (), "#1");
+
+ codeNamespace.Name = "A";
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "namespace A {{{0}" +
+ " using System;{0}" +
+ " using System.Collections;{0}" +
+ " {0}" +
+ "}}{0}", NewLine), Generate (), "#2");
+
+ codeNamespace.Name = null;
+ codeNamespace.Comments.Add (new CodeCommentStatement ("a"));
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "// a{0}" +
+ "using System;{0}" +
+ "using System.Collections;{0}" +
+ "{0}", NewLine), Generate (), "#3");
+
+ codeNamespace.Name = "A";
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "// a{0}" +
+ "namespace A {{{0}" +
+ " using System;{0}" +
+ " using System.Collections;{0}" +
+ " {0}" +
+ "}}{0}", NewLine), Generate (), "#4");
+ }
+
+ [Test]
+ public void TypeTest ()
+ {
+ codeNamespace.Types.Add (new CodeTypeDeclaration ("Person"));
+ Assert.AreEqual (string.Format(CultureInfo.InvariantCulture,
+ "{0}" +
+ "{0}" +
+ "public class Person {{{0}" +
+ "}}{0}", NewLine), Generate (), "#A1");
+
+ CodeGeneratorOptions options = new CodeGeneratorOptions ();
+ options.BlankLinesBetweenMembers = false;
+ Assert.AreEqual (string.Format(CultureInfo.InvariantCulture,
+ "{0}" +
+ "public class Person {{{0}" +
+ "}}{0}", NewLine), Generate (options), "#A2");
+
+ codeNamespace.Name = "A";
+ Assert.AreEqual (string.Format(CultureInfo.InvariantCulture,
+ "namespace A {{{0}" +
+ " {0}" +
+ " {0}" +
+ " public class Person {{{0}" +
+ " }}{0}" +
+ "}}{0}", NewLine), Generate (), "#B1");
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "namespace A {{{0}" +
+ " {0}" +
+ " public class Person {{{0}" +
+ " }}{0}" +
+ "}}{0}", NewLine), Generate (options), "#B2");
+ }
}
}