// Microsoft.VisualBasic.* Test Cases
//
// Authors:
-// Gert Driesen (drieseng@users.sourceforge.net)
+// Gert Driesen (drieseng@users.sourceforge.net)
//
// (c) 2005 Novell
//
+ "Namespace{0}", NewLine), Generate ());
}
+ [Test]
+ public void AttributeAndImportsTest ()
+ {
+ CodeNamespace ns = new CodeNamespace ();
+ codeUnit.Namespaces.Add (ns);
+ ns.Imports.Add(new CodeNamespaceImport("System"));
+ ns.Imports.Add(new CodeNamespaceImport("System.Reflection"));
+
+ CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
+ attrDec.Name = "A";
+ codeUnit.AssemblyCustomAttributes.Add (attrDec);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "Imports System{0}Imports System.Reflection{0}<Assembly: A()> {0}{0}",
+ NewLine), Generate ());
+ }
+
+ [Test]
+ public void AttributeAndImportsAndNamespaceTest ()
+ {
+ CodeNamespace ns = new CodeNamespace ("A");
+ codeUnit.Namespaces.Add (ns);
+ ns.Imports.Add(new CodeNamespaceImport("System"));
+ ns.Imports.Add(new CodeNamespaceImport("System.Reflection"));
+
+ CodeAttributeDeclaration attrDec = new CodeAttributeDeclaration ();
+ attrDec.Name = "A";
+ codeUnit.AssemblyCustomAttributes.Add (attrDec);
+
+ Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
+ "Imports System{0}Imports System.Reflection{0}<Assembly: A()> {0}{0}"
+ + "Namespace A{0}End Namespace{0}", NewLine), Generate ());
+ }
+
[Test]
public void CodeSnippetTest ()
{
writer.Close ();
Assert.AreEqual (sb.ToString () + NewLine, writer.ToString());
}
+
+ [Test]
+ public void ExternalSourceTest ()
+ {
+ CodeSnippetCompileUnit snippet;
+
+ StringBuilder sb = new StringBuilder();
+ sb.Append ("\n");
+ sb.Append ("#ExternalSource(\"file.vb\",123)");
+ sb.Append ("\n");
+ sb.Append ("\n");
+ sb.Append ("\n");
+ sb.Append ("#End ExternalSource");
+ sb.Append ("\n");
+
+ StringWriter writer = new StringWriter ();
+ writer.NewLine = NewLine;
+
+ codeUnit = new CodeSnippetCompileUnit ("");
+ snippet = (CodeSnippetCompileUnit) codeUnit;
+ snippet.LinePragma = new CodeLinePragma ("file.vb", 123);
+ generator.GenerateCodeFromCompileUnit (codeUnit, writer, options);
+ writer.Close ();
+ Assert.AreEqual (sb.ToString (), writer.ToString());
+ }
}
}