CodeCompilerCas.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. //
  2. // CodeCompilerCas.cs
  3. // - CAS unit tests for System.CodeDom.Compiler.CodeCompiler
  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;
  32. using System.CodeDom.Compiler;
  33. using System.IO;
  34. using System.Reflection;
  35. using System.Security;
  36. using System.Security.Permissions;
  37. namespace MonoCasTests.System.CodeDom.Compiler {
  38. class CodeCompilerTest : CodeCompiler {
  39. public CodeCompilerTest ()
  40. {
  41. }
  42. protected override string CmdArgsFromParameters (CompilerParameters options)
  43. {
  44. return String.Empty;
  45. }
  46. protected override string CompilerName {
  47. get { return String.Empty; }
  48. }
  49. protected override string FileExtension {
  50. get { return String.Empty; }
  51. }
  52. protected override void ProcessCompilerOutputLine (CompilerResults results, string line)
  53. {
  54. }
  55. protected override string CreateEscapedIdentifier (string value)
  56. {
  57. return String.Empty;
  58. }
  59. protected override string CreateValidIdentifier (string value)
  60. {
  61. return String.Empty;
  62. }
  63. protected override void GenerateArgumentReferenceExpression (CodeArgumentReferenceExpression e)
  64. {
  65. }
  66. protected override void GenerateArrayCreateExpression (CodeArrayCreateExpression e)
  67. {
  68. }
  69. protected override void GenerateArrayIndexerExpression (CodeArrayIndexerExpression e)
  70. {
  71. }
  72. protected override void GenerateAssignStatement (CodeAssignStatement e)
  73. {
  74. }
  75. protected override void GenerateAttachEventStatement (CodeAttachEventStatement e)
  76. {
  77. }
  78. protected override void GenerateAttributeDeclarationsEnd (CodeAttributeDeclarationCollection attributes)
  79. {
  80. }
  81. protected override void GenerateAttributeDeclarationsStart (CodeAttributeDeclarationCollection attributes)
  82. {
  83. }
  84. protected override void GenerateBaseReferenceExpression (CodeBaseReferenceExpression e)
  85. {
  86. }
  87. protected override void GenerateCastExpression (CodeCastExpression e)
  88. {
  89. }
  90. protected override void GenerateComment (CodeComment e)
  91. {
  92. }
  93. protected override void GenerateConditionStatement (CodeConditionStatement e)
  94. {
  95. }
  96. protected override void GenerateConstructor (CodeConstructor e, CodeTypeDeclaration c)
  97. {
  98. }
  99. protected override void GenerateDelegateCreateExpression (CodeDelegateCreateExpression e)
  100. {
  101. }
  102. protected override void GenerateDelegateInvokeExpression (CodeDelegateInvokeExpression e)
  103. {
  104. }
  105. protected override void GenerateEntryPointMethod (CodeEntryPointMethod e, CodeTypeDeclaration c)
  106. {
  107. }
  108. protected override void GenerateEvent (CodeMemberEvent e, CodeTypeDeclaration c)
  109. {
  110. }
  111. protected override void GenerateEventReferenceExpression (CodeEventReferenceExpression e)
  112. {
  113. }
  114. protected override void GenerateExpressionStatement (CodeExpressionStatement e)
  115. {
  116. }
  117. protected override void GenerateField (CodeMemberField e)
  118. {
  119. }
  120. protected override void GenerateFieldReferenceExpression (CodeFieldReferenceExpression e)
  121. {
  122. }
  123. protected override void GenerateGotoStatement (CodeGotoStatement e)
  124. {
  125. }
  126. protected override void GenerateIndexerExpression (CodeIndexerExpression e)
  127. {
  128. }
  129. protected override void GenerateIterationStatement (CodeIterationStatement e)
  130. {
  131. }
  132. protected override void GenerateLabeledStatement (CodeLabeledStatement e)
  133. {
  134. }
  135. protected override void GenerateLinePragmaEnd (CodeLinePragma e)
  136. {
  137. }
  138. protected override void GenerateLinePragmaStart (CodeLinePragma e)
  139. {
  140. }
  141. protected override void GenerateMethod (CodeMemberMethod e, CodeTypeDeclaration c)
  142. {
  143. }
  144. protected override void GenerateMethodInvokeExpression (CodeMethodInvokeExpression e)
  145. {
  146. }
  147. protected override void GenerateMethodReferenceExpression (CodeMethodReferenceExpression e)
  148. {
  149. }
  150. protected override void GenerateMethodReturnStatement (CodeMethodReturnStatement e)
  151. {
  152. }
  153. protected override void GenerateNamespaceEnd (CodeNamespace e)
  154. {
  155. }
  156. protected override void GenerateNamespaceImport (CodeNamespaceImport e)
  157. {
  158. }
  159. protected override void GenerateNamespaceStart (CodeNamespace e)
  160. {
  161. }
  162. protected override void GenerateObjectCreateExpression (CodeObjectCreateExpression e)
  163. {
  164. }
  165. protected override void GenerateProperty (CodeMemberProperty e, CodeTypeDeclaration c)
  166. {
  167. }
  168. protected override void GeneratePropertyReferenceExpression (CodePropertyReferenceExpression e)
  169. {
  170. }
  171. protected override void GeneratePropertySetValueReferenceExpression (CodePropertySetValueReferenceExpression e)
  172. {
  173. }
  174. protected override void GenerateRemoveEventStatement (CodeRemoveEventStatement e)
  175. {
  176. }
  177. protected override void GenerateSnippetExpression (CodeSnippetExpression e)
  178. {
  179. }
  180. protected override void GenerateSnippetMember (CodeSnippetTypeMember e)
  181. {
  182. }
  183. protected override void GenerateThisReferenceExpression (CodeThisReferenceExpression e)
  184. {
  185. }
  186. protected override void GenerateThrowExceptionStatement (CodeThrowExceptionStatement e)
  187. {
  188. }
  189. protected override void GenerateTryCatchFinallyStatement (CodeTryCatchFinallyStatement e)
  190. {
  191. }
  192. protected override void GenerateTypeConstructor (CodeTypeConstructor e)
  193. {
  194. }
  195. protected override void GenerateTypeEnd (CodeTypeDeclaration e)
  196. {
  197. }
  198. protected override void GenerateTypeStart (CodeTypeDeclaration e)
  199. {
  200. }
  201. protected override void GenerateVariableDeclarationStatement (CodeVariableDeclarationStatement e)
  202. {
  203. }
  204. protected override void GenerateVariableReferenceExpression (CodeVariableReferenceExpression e)
  205. {
  206. }
  207. protected override string GetTypeOutput (CodeTypeReference value)
  208. {
  209. return String.Empty;
  210. }
  211. protected override bool IsValidIdentifier (string value)
  212. {
  213. return true;
  214. }
  215. protected override string NullToken {
  216. get { return String.Empty; }
  217. }
  218. protected override void OutputType (CodeTypeReference typeRef)
  219. {
  220. }
  221. protected override string QuoteSnippetString (string value)
  222. {
  223. return String.Empty;
  224. }
  225. protected override bool Supports (GeneratorSupport support)
  226. {
  227. return true;
  228. }
  229. // publicity
  230. public CompilerResults _FromDom (CompilerParameters options, CodeCompileUnit e)
  231. {
  232. return FromDom (options, e);
  233. }
  234. public CompilerResults _FromDomBatch (CompilerParameters options, CodeCompileUnit[] ea)
  235. {
  236. return FromDomBatch (options, ea);
  237. }
  238. public CompilerResults _FromFile (CompilerParameters options, string fileName)
  239. {
  240. return FromFile (options, fileName);
  241. }
  242. public CompilerResults _FromFileBatch (CompilerParameters options, string[] fileNames)
  243. {
  244. return FromFileBatch (options, fileNames);
  245. }
  246. public CompilerResults _FromSource (CompilerParameters options, string source)
  247. {
  248. return FromSource (options, source);
  249. }
  250. public CompilerResults _FromSourceBatch (CompilerParameters options, string[] sources)
  251. {
  252. return FromSourceBatch (options, sources);
  253. }
  254. public string _GetResponseFileCmdArgs (CompilerParameters options, string cmdArgs)
  255. {
  256. return GetResponseFileCmdArgs (options, cmdArgs);
  257. }
  258. static public string _JoinStringArray (string[] sa, string separator)
  259. {
  260. return CodeCompiler.JoinStringArray (sa, separator);
  261. }
  262. }
  263. [TestFixture]
  264. [Category ("CAS")]
  265. public class CodeCompilerCas {
  266. private string filename;
  267. [TestFixtureSetUp]
  268. public void FixtureSetUp ()
  269. {
  270. // at full trust
  271. filename = Path.GetTempFileName ();
  272. }
  273. [SetUp]
  274. public void SetUp ()
  275. {
  276. if (!SecurityManager.SecurityEnabled)
  277. Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
  278. }
  279. [Test]
  280. [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
  281. [EnvironmentPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  282. [FileIOPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  283. [ExpectedException (typeof (InvalidOperationException))]
  284. public void FromDom_PermitOnly ()
  285. {
  286. CodeCompilerTest cc = new CodeCompilerTest ();
  287. cc._FromDom (new CompilerParameters (), new CodeCompileUnit ());
  288. }
  289. [Test]
  290. [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
  291. [ExpectedException (typeof (SecurityException))]
  292. public void FromDom_Deny_UnmanagedCode ()
  293. {
  294. CodeCompilerTest cc = new CodeCompilerTest ();
  295. cc._FromDom (new CompilerParameters (), new CodeCompileUnit ());
  296. }
  297. [Test]
  298. [FileIOPermission (SecurityAction.Deny, Unrestricted = true)]
  299. [ExpectedException (typeof (SecurityException))]
  300. public void FromDom_Deny_FileIO ()
  301. {
  302. CodeCompilerTest cc = new CodeCompilerTest ();
  303. cc._FromDom (new CompilerParameters (), new CodeCompileUnit ());
  304. }
  305. [Test]
  306. [EnvironmentPermission (SecurityAction.Deny, Unrestricted = true)]
  307. [ExpectedException (typeof (SecurityException))]
  308. #if ONLY_1_1
  309. [Category ("NotDotNet")] // MS doesn't check for Environment under 1.x
  310. #endif
  311. public void FromDom_Deny_Environment ()
  312. {
  313. CodeCompilerTest cc = new CodeCompilerTest ();
  314. cc._FromDom (new CompilerParameters (), new CodeCompileUnit ());
  315. }
  316. [Test]
  317. [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
  318. [EnvironmentPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  319. [FileIOPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  320. [ExpectedException (typeof (InvalidOperationException))]
  321. public void FromDomBatch_PermitOnly ()
  322. {
  323. CodeCompilerTest cc = new CodeCompilerTest ();
  324. cc._FromDomBatch (new CompilerParameters (), new CodeCompileUnit[] { new CodeCompileUnit () });
  325. }
  326. [Test]
  327. [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
  328. [ExpectedException (typeof (SecurityException))]
  329. public void FromDomBatch_Deny_UnmanagedCode ()
  330. {
  331. CodeCompilerTest cc = new CodeCompilerTest ();
  332. cc._FromDomBatch (new CompilerParameters (), new CodeCompileUnit[] { new CodeCompileUnit () });
  333. }
  334. [Test]
  335. [FileIOPermission (SecurityAction.Deny, Unrestricted = true)]
  336. [ExpectedException (typeof (SecurityException))]
  337. public void FromDomBatch_Deny_FileIO ()
  338. {
  339. CodeCompilerTest cc = new CodeCompilerTest ();
  340. cc._FromDomBatch (new CompilerParameters (), new CodeCompileUnit[] { new CodeCompileUnit () });
  341. }
  342. [Test]
  343. [EnvironmentPermission (SecurityAction.Deny, Unrestricted = true)]
  344. [ExpectedException (typeof (SecurityException))]
  345. #if ONLY_1_1
  346. [Category ("NotDotNet")] // MS doesn't check for Environment under 1.x
  347. #endif
  348. public void FromDomBatch_Deny_Environment ()
  349. {
  350. CodeCompilerTest cc = new CodeCompilerTest ();
  351. cc._FromDomBatch (new CompilerParameters (), new CodeCompileUnit[] { new CodeCompileUnit () });
  352. }
  353. [Test]
  354. [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
  355. [EnvironmentPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  356. [FileIOPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  357. [ExpectedException (typeof (InvalidOperationException))]
  358. public void FromFile_PermitOnly ()
  359. {
  360. CodeCompilerTest cc = new CodeCompilerTest ();
  361. cc._FromFile (new CompilerParameters (), filename);
  362. }
  363. [Test]
  364. [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
  365. [ExpectedException (typeof (SecurityException))]
  366. public void FromFile_Deny_UnmanagedCode ()
  367. {
  368. CodeCompilerTest cc = new CodeCompilerTest ();
  369. cc._FromFile (new CompilerParameters (), String.Empty);
  370. }
  371. [Test]
  372. [FileIOPermission (SecurityAction.Deny, Unrestricted = true)]
  373. [ExpectedException (typeof (SecurityException))]
  374. public void FromFile_Deny_FileIO ()
  375. {
  376. CodeCompilerTest cc = new CodeCompilerTest ();
  377. cc._FromFile (new CompilerParameters (), filename);
  378. }
  379. [Test]
  380. [EnvironmentPermission (SecurityAction.Deny, Unrestricted = true)]
  381. [ExpectedException (typeof (SecurityException))]
  382. #if ONLY_1_1
  383. [Category ("NotDotNet")] // MS doesn't check for Environment under 1.x
  384. #endif
  385. public void FromFile_Deny_Environment ()
  386. {
  387. CodeCompilerTest cc = new CodeCompilerTest ();
  388. cc._FromFile (new CompilerParameters (), filename);
  389. }
  390. [Test]
  391. [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
  392. [EnvironmentPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  393. [FileIOPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  394. [ExpectedException (typeof (InvalidOperationException))]
  395. public void FromFileBatch_PermitOnly ()
  396. {
  397. CodeCompilerTest cc = new CodeCompilerTest ();
  398. cc._FromFileBatch (new CompilerParameters (), new string[] { String.Empty });
  399. }
  400. [Test]
  401. [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
  402. [ExpectedException (typeof (SecurityException))]
  403. public void FromFileBatch_Deny_UnmanagedCode ()
  404. {
  405. CodeCompilerTest cc = new CodeCompilerTest ();
  406. cc._FromFileBatch (new CompilerParameters (), new string[] { String.Empty });
  407. }
  408. [Test]
  409. [FileIOPermission (SecurityAction.Deny, Unrestricted = true)]
  410. [ExpectedException (typeof (SecurityException))]
  411. public void FromFileBatch_Deny_FileIO ()
  412. {
  413. CodeCompilerTest cc = new CodeCompilerTest ();
  414. cc._FromFileBatch (new CompilerParameters (), new string[] { String.Empty });
  415. }
  416. [Test]
  417. [EnvironmentPermission (SecurityAction.Deny, Unrestricted = true)]
  418. [ExpectedException (typeof (SecurityException))]
  419. #if ONLY_1_1
  420. [Category ("NotDotNet")] // MS doesn't check for Environment under 1.x
  421. #endif
  422. public void FromFileBatch_Deny_Environment ()
  423. {
  424. CodeCompilerTest cc = new CodeCompilerTest ();
  425. cc._FromFileBatch (new CompilerParameters (), new string[] { String.Empty });
  426. }
  427. [Test]
  428. [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
  429. [EnvironmentPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  430. [FileIOPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  431. [ExpectedException (typeof (InvalidOperationException))]
  432. public void FromSource_PermitOnly ()
  433. {
  434. CodeCompilerTest cc = new CodeCompilerTest ();
  435. cc._FromSource (new CompilerParameters (), String.Empty);
  436. }
  437. [Test]
  438. [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
  439. [ExpectedException (typeof (SecurityException))]
  440. public void FromSource_Deny_UnmanagedCode ()
  441. {
  442. CodeCompilerTest cc = new CodeCompilerTest ();
  443. cc._FromSource (new CompilerParameters (), String.Empty);
  444. }
  445. [Test]
  446. [FileIOPermission (SecurityAction.Deny, Unrestricted = true)]
  447. [ExpectedException (typeof (SecurityException))]
  448. public void FromSource_Deny_FileIO ()
  449. {
  450. CodeCompilerTest cc = new CodeCompilerTest ();
  451. cc._FromSource (new CompilerParameters (), String.Empty);
  452. }
  453. [Test]
  454. [EnvironmentPermission (SecurityAction.Deny, Unrestricted = true)]
  455. [ExpectedException (typeof (SecurityException))]
  456. #if ONLY_1_1
  457. [Category ("NotDotNet")] // MS doesn't check for Environment under 1.x
  458. #endif
  459. public void FromSource_Deny_Environment ()
  460. {
  461. CodeCompilerTest cc = new CodeCompilerTest ();
  462. cc._FromSource (new CompilerParameters (), String.Empty);
  463. }
  464. [Test]
  465. [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
  466. [EnvironmentPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  467. [FileIOPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  468. [ExpectedException (typeof (InvalidOperationException))]
  469. public void FromSourceBatch_PermitOnly ()
  470. {
  471. CodeCompilerTest cc = new CodeCompilerTest ();
  472. cc._FromSourceBatch (new CompilerParameters (), new string[] { String.Empty });
  473. }
  474. [Test]
  475. [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
  476. [ExpectedException (typeof (SecurityException))]
  477. public void FromSourceBatch_Deny_UnmanagedCode ()
  478. {
  479. CodeCompilerTest cc = new CodeCompilerTest ();
  480. cc._FromSourceBatch (new CompilerParameters (), new string[] { String.Empty });
  481. }
  482. [Test]
  483. [FileIOPermission (SecurityAction.Deny, Unrestricted = true)]
  484. [ExpectedException (typeof (SecurityException))]
  485. public void FromSourceBatch_Deny_FileIO ()
  486. {
  487. CodeCompilerTest cc = new CodeCompilerTest ();
  488. cc._FromSourceBatch (new CompilerParameters (), new string[] { String.Empty });
  489. }
  490. [Test]
  491. [EnvironmentPermission (SecurityAction.Deny, Unrestricted = true)]
  492. [ExpectedException (typeof (SecurityException))]
  493. #if ONLY_1_1
  494. [Category ("NotDotNet")] // MS doesn't check for Environment under 1.x
  495. #endif
  496. public void FromSourceBatch_Deny_Environment ()
  497. {
  498. CodeCompilerTest cc = new CodeCompilerTest ();
  499. cc._FromSourceBatch (new CompilerParameters (), new string[] { String.Empty });
  500. }
  501. [Test]
  502. [EnvironmentPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  503. [FileIOPermission (SecurityAction.PermitOnly, Unrestricted = true)]
  504. public void GetResponseFileCmdArgs_PermitOnly ()
  505. {
  506. CodeCompilerTest cc = new CodeCompilerTest ();
  507. try {
  508. Assert.IsNotNull (cc._GetResponseFileCmdArgs (new CompilerParameters (), String.Empty));
  509. }
  510. catch (NotImplementedException) {
  511. // mono
  512. }
  513. }
  514. [Test]
  515. [EnvironmentPermission (SecurityAction.Deny, Unrestricted = true)]
  516. [ExpectedException (typeof (SecurityException))]
  517. #if ONLY_1_1
  518. [Category ("NotDotNet")] // MS doesn't check for Environment under 1.x
  519. #endif
  520. public void GetResponseFileCmdArgs_Deny_Environment ()
  521. {
  522. CodeCompilerTest cc = new CodeCompilerTest ();
  523. try {
  524. cc._GetResponseFileCmdArgs (new CompilerParameters (), String.Empty);
  525. }
  526. catch (NotImplementedException) {
  527. Assert.Ignore ("GetResponseFileCmdArgs not implemented");
  528. }
  529. }
  530. [Test]
  531. [FileIOPermission (SecurityAction.Deny, Unrestricted = true)]
  532. [ExpectedException (typeof (SecurityException))]
  533. public void GetResponseFileCmdArgs_Deny_FileIO ()
  534. {
  535. CodeCompilerTest cc = new CodeCompilerTest ();
  536. try {
  537. cc._GetResponseFileCmdArgs (new CompilerParameters (), String.Empty);
  538. }
  539. catch (NotImplementedException) {
  540. Assert.Ignore ("GetResponseFileCmdArgs not implemented");
  541. }
  542. }
  543. [Test]
  544. [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
  545. public void JoinStringArray ()
  546. {
  547. string[] data = new string[] { "a", "b", "c" };
  548. Assert.AreEqual ("\"a\"#\"b\"#\"c\"", CodeCompilerTest._JoinStringArray (data, "#"), "JoinStringArray");
  549. }
  550. [Test]
  551. [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
  552. public void LinkDemand_Deny_Unrestricted ()
  553. {
  554. ConstructorInfo ci = typeof (CodeCompilerTest).GetConstructor (new Type[0]);
  555. Assert.IsNotNull (ci, "default .ctor()");
  556. Assert.IsNotNull (ci.Invoke (null), "invoke");
  557. }
  558. }
  559. }