1 //
2 // ManagedCompilerTest.cs
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 //
7 // (C) 2006 Marek Sieradzki
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 
28 using System;
29 using System.IO;
30 using System.Collections;
31 using Microsoft.Build.BuildEngine;
32 using Microsoft.Build.Framework;
33 using Microsoft.Build.Tasks;
34 using Microsoft.Build.Utilities;
35 using NUnit.Framework;
36 
37 namespace MonoTests.Microsoft.Build.Tasks {
38 
39 	class MCExtended : ManagedCompiler {
MCExtended()40 		public MCExtended ()
41 			: base ()
42 		{
43 		}
44 
ARFC(CommandLineBuilderExtension commandLine)45 		public void ARFC (CommandLineBuilderExtension commandLine)
46 		{
47 			base.AddResponseFileCommands (commandLine);
48 		}
49 
ACLC(CommandLineBuilderExtension commandLine)50 		public void ACLC (CommandLineBuilderExtension commandLine)
51 		{
52 			base.AddCommandLineCommands (commandLine);
53 		}
54 
CheckAllReferencesExistOnDisk()55 		public new bool CheckAllReferencesExistOnDisk ()
56 		{
57 			return base.CheckAllReferencesExistOnDisk ();
58 		}
59 
60 
61 		protected override string ToolName {
62 			get { return "something"; }
63 		}
64 
GenerateFullPathToTool()65 		protected override string GenerateFullPathToTool ()
66 		{
67 			return null;
68 		}
69 	}
70 
71 	[TestFixture]
72 	public class ManagedCompilerTest {
73 
74 		[Test]
TestAssignment()75 		public void TestAssignment ()
76 		{
77 			MCExtended mc = new MCExtended ();
78 
79 			mc.AdditionalLibPaths = new string [1] { "1" };
80 			mc.AddModules = new string [1] { "2" };
81 			mc.CodePage = 3;
82 			mc.DebugType = "4";
83 			mc.DefineConstants = "5";
84 			mc.DelaySign = true;
85 			mc.EmitDebugInformation = true;
86 			mc.FileAlignment = 6;
87 			mc.KeyContainer = "7";
88 			mc.KeyFile = "8";
89 			mc.LinkResources = new ITaskItem [1] { new TaskItem ("9") };
90 			mc.MainEntryPoint = "10";
91 			mc.NoConfig = true;
92 			mc.NoLogo = true;
93 			mc.Optimize = true;
94 			mc.OutputAssembly = new TaskItem ("11");
95 			mc.References = new ITaskItem [1] { new TaskItem ("12") };
96 			mc.Resources = new ITaskItem [1] { new TaskItem ("13") };
97 			mc.ResponseFiles = new ITaskItem [1] { new TaskItem ("14") };
98 			mc.Sources = new ITaskItem [1] { new TaskItem ("15") };
99 			mc.TargetType = "16";
100 			mc.TreatWarningsAsErrors = true;
101 			mc.Utf8Output = true;
102 			mc.Win32Icon = "17";
103 			mc.Win32Resource = "18";
104 
105 			Assert.AreEqual ("1", mc.AdditionalLibPaths [0], "A1");
106 			Assert.AreEqual ("2", mc.AddModules [0], "A2");
107 			Assert.AreEqual (3, mc.CodePage, "A3");
108 			Assert.AreEqual ("4", mc.DebugType, "A4");
109 			Assert.AreEqual ("5", mc.DefineConstants, "A5");
110 			Assert.AreEqual (true, mc.DelaySign, "A6");
111 			Assert.AreEqual (true, mc.EmitDebugInformation, "A7");
112 			Assert.AreEqual (6, mc.FileAlignment, "A8");
113 			Assert.AreEqual ("7", mc.KeyContainer, "A9");
114 			Assert.AreEqual ("8", mc.KeyFile, "A10");
115 			Assert.AreEqual ("9", mc.LinkResources [0].ItemSpec, "A11");
116 			Assert.AreEqual ("10", mc.MainEntryPoint, "A12");
117 			Assert.AreEqual (true, mc.NoConfig, "A13");
118 			Assert.AreEqual (true, mc.NoLogo, "A14");
119 			Assert.AreEqual (true, mc.Optimize, "A15");
120 			Assert.AreEqual ("11", mc.OutputAssembly.ItemSpec, "A16");
121 			Assert.AreEqual ("12", mc.References [0].ItemSpec, "A17");
122 			Assert.AreEqual ("13", mc.Resources [0].ItemSpec, "A18");
123 			Assert.AreEqual ("14", mc.ResponseFiles [0].ItemSpec, "A19");
124 			Assert.AreEqual ("15", mc.Sources [0].ItemSpec, "A20");
125 			Assert.AreEqual ("16", mc.TargetType, "A21");
126 			Assert.AreEqual (true, mc.TreatWarningsAsErrors, "A22");
127 			Assert.AreEqual (true, mc.Utf8Output, "A23");
128 			Assert.AreEqual ("17", mc.Win32Icon, "A24");
129 			Assert.AreEqual ("18", mc.Win32Resource, "A25");
130 		}
131 
132 		[Test]
TestDefaultValues()133 		public void TestDefaultValues ()
134 		{
135 			MCExtended mc = new MCExtended ();
136 
137 			Assert.IsNull (mc.AdditionalLibPaths, "A1");
138 			Assert.IsNull (mc.AddModules, "A2");
139 			Assert.AreEqual (0, mc.CodePage, "A3");
140 			Assert.IsNull (mc.DebugType, "A4");
141 			Assert.IsNull (mc.DefineConstants, "A5");
142 			Assert.IsFalse (mc.DelaySign, "A6");
143 			Assert.IsFalse (mc.EmitDebugInformation, "A7");
144 			Assert.AreEqual (0, mc.FileAlignment, "A8");
145 			Assert.IsNull (mc.KeyContainer, "A9");
146 			Assert.IsNull (mc.KeyFile, "A10");
147 			Assert.IsNull (mc.LinkResources, "A11");
148 			Assert.IsNull (mc.MainEntryPoint, "A12");
149 			Assert.IsFalse (mc.NoConfig, "A13");
150 			Assert.IsFalse (mc.NoLogo, "A14");
151 			Assert.IsFalse (mc.Optimize, "A15");
152 			Assert.IsNull (mc.OutputAssembly, "A16");
153 			Assert.IsNull (mc.References, "A17");
154 			Assert.IsNull (mc.Resources, "A18");
155 			Assert.IsNull (mc.ResponseFiles, "A19");
156 			Assert.IsNull (mc.Sources, "A20");
157 			Assert.IsNull (mc.TargetType, "A21");
158 			Assert.IsFalse (mc.TreatWarningsAsErrors, "A22");
159 			Assert.IsFalse (mc.Utf8Output, "A23");
160 			Assert.IsNull (mc.Win32Icon, "A24");
161 			Assert.IsNull (mc.Win32Resource, "A25");
162 		}
163 
164 		[Test]
TestAdditionalLibPaths()165 		public void TestAdditionalLibPaths ()
166 		{
167 			MCExtended mc = new MCExtended ();
168 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
169 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
170 
171 			mc.AdditionalLibPaths = new string [2] { "A", "B" };
172 			mc.ARFC (c1);
173 			mc.ACLC (c2);
174 
175 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
176 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
177 		}
178 
179 		[Test]
TestAddModules()180 		public void TestAddModules ()
181 		{
182 			MCExtended mc = new MCExtended ();
183 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
184 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
185 
186 			mc.AddModules = new string [2] { "A", "B" };
187 			mc.ARFC (c1);
188 			mc.ACLC (c2);
189 
190 			Assert.AreEqual ("/addmodule:A,B", c1.ToString (), "A1");
191 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
192 		}
193 
194 		[Test]
TestCodePage1()195 		public void TestCodePage1 ()
196 		{
197 			MCExtended mc = new MCExtended ();
198 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
199 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
200 
201 			mc.CodePage = 1111;
202 			mc.ARFC (c1);
203 			mc.ACLC (c2);
204 
205 			Assert.AreEqual ("/codepage:1111", c1.ToString (), "A1");
206 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
207 		}
208 
209 		[Test]
TestCodePage2()210 		public void TestCodePage2 ()
211 		{
212 			MCExtended mc = new MCExtended ();
213 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
214 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
215 
216 			mc.ARFC (c1);
217 			mc.ACLC (c2);
218 
219 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
220 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
221 		}
222 
223 		[Test]
TestDebugType()224 		public void TestDebugType ()
225 		{
226 			MCExtended mc = new MCExtended ();
227 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
228 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
229 
230 			mc.DebugType = "A";
231 			mc.ARFC (c1);
232 			mc.ACLC (c2);
233 
234 			Assert.AreEqual ("/debug:A", c1.ToString (), "A1");
235 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
236 		}
237 
238 		[Test]
TestDefineConstants()239 		public void TestDefineConstants ()
240 		{
241 			MCExtended mc = new MCExtended ();
242 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
243 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
244 
245 			mc.DefineConstants = "A;B";
246 			mc.ARFC (c1);
247 			mc.ACLC (c2);
248 
249 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
250 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
251 		}
252 
253 		[Test]
TestDelaySign1()254 		public void TestDelaySign1 ()
255 		{
256 			MCExtended mc = new MCExtended ();
257 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
258 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
259 
260 			mc.DelaySign = true;
261 			mc.ARFC (c1);
262 			mc.ACLC (c2);
263 
264 			Assert.AreEqual ("/delaysign+", c1.ToString (), "A1");
265 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
266 		}
267 
268 		[Test]
TestDelaySign2()269 		public void TestDelaySign2 ()
270 		{
271 			MCExtended mc = new MCExtended ();
272 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
273 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
274 
275 			mc.DelaySign = false;
276 			mc.ARFC (c1);
277 			mc.ACLC (c2);
278 
279 			Assert.AreEqual ("/delaysign-", c1.ToString (), "A1");
280 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
281 		}
282 
283 		[Test]
TestEmitDebugInformation1()284 		public void TestEmitDebugInformation1 ()
285 		{
286 			MCExtended mc = new MCExtended ();
287 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
288 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
289 
290 			mc.EmitDebugInformation = true;
291 			mc.ARFC (c1);
292 			mc.ACLC (c2);
293 
294 			Assert.AreEqual ("/debug:portable", c1.ToString (), "A1");
295 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
296 		}
297 
298 		[Test]
TestEmitDebugInformation2()299 		public void TestEmitDebugInformation2 ()
300 		{
301 			MCExtended mc = new MCExtended ();
302 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
303 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
304 
305 			mc.EmitDebugInformation = false;
306 			mc.ARFC (c1);
307 			mc.ACLC (c2);
308 
309 			Assert.AreEqual ("/debug-", c1.ToString (), "A1");
310 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
311 		}
312 
313 		[Test]
314 		[Category ("NotWorking")]
TestFileAlignment1()315 		public void TestFileAlignment1 ()
316 		{
317 			MCExtended mc = new MCExtended ();
318 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
319 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
320 
321 			mc.FileAlignment = 100;
322 			mc.ARFC (c1);
323 			mc.ACLC (c2);
324 
325 			Assert.AreEqual ("/filealign:100", c1.ToString (), "A1");
326 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
327 		}
328 
329 		[Test]
TestFileAlignment2()330 		public void TestFileAlignment2 ()
331 		{
332 			MCExtended mc = new MCExtended ();
333 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
334 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
335 
336 			mc.ARFC (c1);
337 			mc.ACLC (c2);
338 
339 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
340 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
341 		}
342 
343 		[Test]
TestKeyContainer()344 		public void TestKeyContainer ()
345 		{
346 			MCExtended mc = new MCExtended ();
347 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
348 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
349 
350 			mc.KeyContainer = "A";
351 			mc.ARFC (c1);
352 			mc.ACLC (c2);
353 
354 			Assert.AreEqual ("/keycontainer:A", c1.ToString (), "A1");
355 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
356 		}
357 
358 		[Test]
TestKeyFile()359 		public void TestKeyFile ()
360 		{
361 			MCExtended mc = new MCExtended ();
362 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
363 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
364 
365 			mc.KeyFile = "A";
366 			mc.ARFC (c1);
367 			mc.ACLC (c2);
368 
369 			Assert.AreEqual ("/keyfile:A /publicsign", c1.ToString (), "A1");
370 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
371 		}
372 
373 		[Test]
TestLinkResources()374 		public void TestLinkResources ()
375 		{
376 			MCExtended mc = new MCExtended ();
377 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
378 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
379 
380 			mc.LinkResources = new ITaskItem [2] { new TaskItem ("A"), new TaskItem ("B") };
381 			mc.ARFC (c1);
382 			mc.ACLC (c2);
383 
384 			Assert.AreEqual ("/linkresource:A /linkresource:B", c1.ToString (), "A1");
385 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
386 		}
387 
388 		[Test]
TestMainEntryPoint()389 		public void TestMainEntryPoint ()
390 		{
391 			MCExtended mc = new MCExtended ();
392 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
393 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
394 
395 			mc.MainEntryPoint = "A";
396 			mc.ARFC (c1);
397 			mc.ACLC (c2);
398 
399 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
400 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
401 		}
402 
403 		[Test]
TestNoConfig1()404 		public void TestNoConfig1 ()
405 		{
406 			MCExtended mc = new MCExtended ();
407 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
408 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
409 
410 			mc.NoConfig = true;
411 			mc.ARFC (c1);
412 			mc.ACLC (c2);
413 
414 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
415 			Assert.AreEqual ("/noconfig", c2.ToString (), "A2");
416 		}
417 
418 		[Test]
TestNoConfig2()419 		public void TestNoConfig2 ()
420 		{
421 			MCExtended mc = new MCExtended ();
422 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
423 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
424 
425 			mc.NoConfig = false;
426 			mc.ARFC (c1);
427 			mc.ACLC (c2);
428 
429 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
430 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
431 		}
432 
433 		[Test]
TestNoLogo1()434 		public void TestNoLogo1 ()
435 		{
436 			MCExtended mc = new MCExtended ();
437 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
438 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
439 
440 			mc.NoLogo = true;
441 			mc.ARFC (c1);
442 			mc.ACLC (c2);
443 
444 			Assert.AreEqual ("/nologo", c1.ToString (), "A1");
445 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
446 		}
447 
448 		[Test]
TestNoLogo2()449 		public void TestNoLogo2 ()
450 		{
451 			MCExtended mc = new MCExtended ();
452 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
453 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
454 
455 			mc.NoLogo = false;
456 			mc.ARFC (c1);
457 			mc.ACLC (c2);
458 
459 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
460 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
461 		}
462 
463 		[Test]
TestOptimize1()464 		public void TestOptimize1 ()
465 		{
466 			MCExtended mc = new MCExtended ();
467 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
468 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
469 
470 			mc.Optimize = true;
471 			mc.ARFC (c1);
472 			mc.ACLC (c2);
473 
474 			Assert.AreEqual ("/optimize+", c1.ToString (), "A1");
475 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
476 		}
477 
478 		[Test]
TestOptimize2()479 		public void TestOptimize2 ()
480 		{
481 			MCExtended mc = new MCExtended ();
482 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
483 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
484 
485 			mc.Optimize = false;
486 			mc.ARFC (c1);
487 			mc.ACLC (c2);
488 
489 			Assert.AreEqual ("/optimize-", c1.ToString (), "A1");
490 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
491 		}
492 
493 		[Test]
TestOutputAssembly()494 		public void TestOutputAssembly ()
495 		{
496 			MCExtended mc = new MCExtended ();
497 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
498 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
499 
500 			mc.OutputAssembly = new TaskItem ("A");
501 			mc.ARFC (c1);
502 			mc.ACLC (c2);
503 
504 			Assert.AreEqual ("/out:A", c1.ToString (), "A1");
505 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
506 		}
507 
508 		[Test]
TestReferences()509 		public void TestReferences ()
510 		{
511 			MCExtended mc = new MCExtended ();
512 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
513 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
514 
515 			mc.References = new ITaskItem [2] { new TaskItem ("A"), new TaskItem ("B") };
516 			mc.ARFC (c1);
517 			mc.ACLC (c2);
518 
519 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
520 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
521 		}
522 
523 		[Test]
TestResources()524 		public void TestResources ()
525 		{
526 			MCExtended mc = new MCExtended ();
527 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
528 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
529 
530 			mc.Resources = new ITaskItem [2] { new TaskItem ("A"), new TaskItem ("B") };
531 			mc.ARFC (c1);
532 			mc.ACLC (c2);
533 
534 			Assert.AreEqual ("/resource:A /resource:B", c1.ToString (), "A1");
535 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
536 		}
537 
538 		[Test]
TestResponseFiles()539 		public void TestResponseFiles ()
540 		{
541 			MCExtended mc = new MCExtended ();
542 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
543 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
544 
545 			mc.ResponseFiles = new ITaskItem [2] { new TaskItem ("A"), new TaskItem ("B") };
546 			mc.ARFC (c1);
547 			mc.ACLC (c2);
548 
549 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
550 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
551 		}
552 
553 		[Test]
TestSources()554 		public void TestSources ()
555 		{
556 			MCExtended mc = new MCExtended ();
557 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
558 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
559 
560 			mc.Sources = new ITaskItem [2] { new TaskItem ("A"), new TaskItem ("B") };
561 			mc.ARFC (c1);
562 			mc.ACLC (c2);
563 
564 			Assert.AreEqual ("/out:A.exe A B", c1.ToString (), "A1");
565 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
566 		}
567 
568 		[Test]
TestTargetType()569 		public void TestTargetType ()
570 		{
571 			MCExtended mc = new MCExtended ();
572 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
573 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
574 
575 			mc.TargetType = "A";
576 			mc.ARFC (c1);
577 			mc.ACLC (c2);
578 
579 			Assert.AreEqual ("/target:a", c1.ToString (), "A1");
580 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
581 		}
582 
583 		[Test]
TestTreatWarningsAsErrors1()584 		public void TestTreatWarningsAsErrors1 ()
585 		{
586 			MCExtended mc = new MCExtended ();
587 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
588 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
589 
590 			mc.TreatWarningsAsErrors = true;
591 			mc.ARFC (c1);
592 			mc.ACLC (c2);
593 
594 			Assert.AreEqual ("/warnaserror+", c1.ToString (), "A1");
595 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
596 		}
597 
598 		[Test]
TestTreatWarningsAsErrors2()599 		public void TestTreatWarningsAsErrors2 ()
600 		{
601 			MCExtended mc = new MCExtended ();
602 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
603 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
604 
605 			mc.TreatWarningsAsErrors = false;
606 			mc.ARFC (c1);
607 			mc.ACLC (c2);
608 
609 			Assert.AreEqual ("/warnaserror-", c1.ToString (), "A1");
610 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
611 		}
612 
613 		[Test]
614 		[Category ("NotWorking")]
TestUtf8Output1()615 		public void TestUtf8Output1 ()
616 		{
617 			MCExtended mc = new MCExtended ();
618 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
619 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
620 
621 			mc.Utf8Output = true;
622 			mc.ARFC (c1);
623 			mc.ACLC (c2);
624 
625 			Assert.AreEqual ("/utf8output", c1.ToString (), "A1");
626 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
627 		}
628 
629 		[Test]
TestUtf8Output2()630 		public void TestUtf8Output2 ()
631 		{
632 			MCExtended mc = new MCExtended ();
633 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
634 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
635 
636 			mc.Utf8Output = false;
637 			mc.ARFC (c1);
638 			mc.ACLC (c2);
639 
640 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
641 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
642 		}
643 
644 		[Test]
TestWin32Icon()645 		public void TestWin32Icon ()
646 		{
647 			MCExtended mc = new MCExtended ();
648 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
649 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
650 
651 			mc.Win32Icon = "A";
652 			mc.ARFC (c1);
653 			mc.ACLC (c2);
654 
655 			Assert.AreEqual ("/win32icon:A", c1.ToString (), "A1");
656 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
657 		}
658 
659 		[Test]
TestWin32Resource()660 		public void TestWin32Resource ()
661 		{
662 			MCExtended mc = new MCExtended ();
663 			CommandLineBuilderExtension c1 = new CommandLineBuilderExtension ();
664 			CommandLineBuilderExtension c2 = new CommandLineBuilderExtension ();
665 
666 			mc.Win32Resource = "A;B";
667 			mc.ARFC (c1);
668 			mc.ACLC (c2);
669 
670 			Assert.AreEqual (String.Empty, c1.ToString (), "A1");
671 			Assert.AreEqual (String.Empty, c2.ToString (), "A2");
672 		}
673 
674 		[Test]
TestCheckAllReferencesExistOnDisk1()675 		public void TestCheckAllReferencesExistOnDisk1 ()
676 		{
677 			MCExtended mc = new MCExtended ();
678 			mc.BuildEngine = new TestEngine ();
679 
680 			mc.References = new ITaskItem [0];
681 			Assert.IsTrue (mc.CheckAllReferencesExistOnDisk (), "A1");
682 
683 			mc.References = null;
684 			Assert.IsTrue (mc.CheckAllReferencesExistOnDisk (), "A2");
685 
686 			string path = Path.Combine (Path.Combine ("Test", "resources"), "test.cs");
687 			mc.References = new ITaskItem [1] { new TaskItem (path) };
688 			Assert.IsTrue (mc.CheckAllReferencesExistOnDisk (), "A3");
689 
690 			mc.References = new ITaskItem [2] { new TaskItem (path), new TaskItem ("X") };
691 			Assert.IsFalse (mc.CheckAllReferencesExistOnDisk (), "A4");
692 		}
693 	}
694 }
695 
696