2 // Microsoft.CSharp.* Test Cases
5 // Erik LeBel (eriklebel@yahoo.ca)
12 using System.CodeDom.Compiler;
14 using NUnit.Framework;
16 namespace MonoTests.Microsoft.CSharp
20 /// Test ICodeGenerator's GenerateCodeFromStatement, along with a
21 /// minimal set CodeDom components.
25 public class CodeGeneratorFromStatementTest: CodeGeneratorTestBase
27 CodeStatement statement = null;
33 statement = new CodeStatement ();
36 protected override void Generate ()
38 generator.GenerateCodeFromStatement (statement, writer, options);
43 [ExpectedException (typeof (ArgumentException))]
44 public void DefaultStatementTest ()
50 [ExpectedException (typeof (NullReferenceException))]
51 public void NullStatementTest ()
58 public void DefaultCodeCommentStatementTest ()
60 CodeCommentStatement commentStatement = new CodeCommentStatement ();
61 CodeComment comment = new CodeComment ();
63 commentStatement.Comment = comment;
64 statement = commentStatement;
67 Assertion.AssertEquals ("// \n", Code);
71 public void MultiLineCodeCommentStatementTest ()
73 CodeCommentStatement commentStatement = new CodeCommentStatement ();
74 CodeComment comment = new CodeComment ();
76 comment.Text = "a\nb";
77 commentStatement.Comment = comment;
78 statement = commentStatement;
81 Assertion.AssertEquals ("// a\n//b\n", Code);
85 public void DefaultThrowExceptionStatementTest ()
87 CodeThrowExceptionStatement throwStatement = new CodeThrowExceptionStatement ();
89 statement = throwStatement;
92 Assertion.AssertEquals ("throw;\n", Code);
97 public void ThrowExceptionStatementTest ()
99 CodeThrowExceptionStatement throwStatement = new CodeThrowExceptionStatement ();
100 throwStatement.ToThrow = ... expression
101 statement = throwStatement ();
104 Assertion.AssertEquals ("", Code);
110 System.CodeDom.CodeObject
111 System.CodeDom.CodeStatement
112 System.CodeDom.CodeAssignStatement
113 System.CodeDom.CodeAttachEventStatement
114 - System.CodeDom.CodeCommentStatement
115 System.CodeDom.CodeConditionStatement
116 System.CodeDom.CodeExpressionStatement
117 System.CodeDom.CodeGotoStatement
118 System.CodeDom.CodeIterationStatement
119 System.CodeDom.CodeLabeledStatement
120 System.CodeDom.CodeMethodReturnStatement
121 System.CodeDom.CodeRemoveEventStatement
122 System.CodeDom.CodeSnippetStatement
123 System.CodeDom.CodeThrowExceptionStatement
124 System.CodeDom.CodeTryCatchFinallyStatement
125 System.CodeDom.CodeVariableDeclarationStatement
132 public void ReferencedTest ()
134 codeUnit.ReferencedAssemblies.Add ("System.dll");
136 Assertion.AssertEquals ("", Code);