(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System / Test / Microsoft.CSharp / CodeGeneratorFromStatementTest.cs
blobd6a178eec1ce175ebafdfe8949e36a4bcb625c2b
1 //
2 // Microsoft.CSharp.* Test Cases
3 //
4 // Authors:
5 // Erik LeBel (eriklebel@yahoo.ca)
6 //
7 // (c) 2003 Erik LeBel
8 //
9 using System;
10 using System.Text;
11 using System.CodeDom;
12 using System.CodeDom.Compiler;
14 using NUnit.Framework;
16 namespace MonoTests.Microsoft.CSharp
18 ///
19 /// <summary>
20 /// Test ICodeGenerator's GenerateCodeFromStatement, along with a
21 /// minimal set CodeDom components.
22 /// </summary>
23 ///
24 [TestFixture]
25 public class CodeGeneratorFromStatementTest: CodeGeneratorTestBase
27 CodeStatement statement = null;
29 [SetUp]
30 public void Init ()
32 InitBase ();
33 statement = new CodeStatement ();
36 protected override void Generate ()
38 generator.GenerateCodeFromStatement (statement, writer, options);
39 writer.Close ();
42 [Test]
43 [ExpectedException (typeof (ArgumentException))]
44 public void DefaultStatementTest ()
46 Generate ();
49 [Test]
50 [ExpectedException (typeof (NullReferenceException))]
51 public void NullStatementTest ()
53 statement = null;
54 Generate ();
57 [Test]
58 public void DefaultCodeCommentStatementTest ()
60 CodeCommentStatement commentStatement = new CodeCommentStatement ();
61 CodeComment comment = new CodeComment ();
63 commentStatement.Comment = comment;
64 statement = commentStatement;
66 Generate ();
67 Assertion.AssertEquals ("// \n", Code);
70 [Test]
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;
80 Generate ();
81 Assertion.AssertEquals ("// a\n//b\n", Code);
84 [Test]
85 public void DefaultThrowExceptionStatementTest ()
87 CodeThrowExceptionStatement throwStatement = new CodeThrowExceptionStatement ();
89 statement = throwStatement;
91 Generate ();
92 Assertion.AssertEquals ("throw;\n", Code);
96 [Test]
97 public void ThrowExceptionStatementTest ()
99 CodeThrowExceptionStatement throwStatement = new CodeThrowExceptionStatement ();
100 throwStatement.ToThrow = ... expression
101 statement = throwStatement ();
103 Generate();
104 Assertion.AssertEquals ("", Code);
109 System.Object
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
131 [Test]
132 public void ReferencedTest ()
134 codeUnit.ReferencedAssemblies.Add ("System.dll");
135 Generate ();
136 Assertion.AssertEquals ("", Code);