5 // Marek Sieradzki (marek.sieradzki@gmail.com)
7 // (C) 2006 Marek Sieradzki
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
29 using System.Collections;
30 using System.Collections.Generic;
31 using Microsoft.Build.BuildEngine;
32 using Microsoft.Build.Framework;
33 using Microsoft.Build.Tasks;
34 using Microsoft.Build.Utilities;
35 using NUnit.Framework;
37 namespace MonoTests.Microsoft.Build.Tasks {
39 class ALExtended : AL {
45 public void ARFC (CommandLineBuilderExtension commandLine)
47 base.AddResponseFileCommands (commandLine);
51 get { return base.ToolName; }
59 public void TestAssignment1 ()
66 al.Configuration = "4";
71 al.EmbedResources = new ITaskItem [1] { new TaskItem ("8") };
72 al.EvidenceFile = "9";
73 al.FileVersion = "10";
75 al.GenerateFullPaths = true;
76 al.KeyContainer = "12";
78 al.LinkResources = new ITaskItem [1] { new TaskItem ("14") };
79 al.MainEntryPoint = "15";
80 al.OutputAssembly = new TaskItem ("16");
82 al.ProductName = "18";
83 al.ProductVersion = "19";
84 al.ResponseFiles = new string [1] { "20" };
85 al.SourceModules = new ITaskItem [1] { new TaskItem ("21") };
87 al.TemplateFile = "23";
92 al.Win32Resource = "28";
94 Assert.AreEqual ("1", al.AlgorithmId, "A1");
95 Assert.AreEqual ("2", al.BaseAddress, "A2");
96 Assert.AreEqual ("3", al.CompanyName, "A3");
97 Assert.AreEqual ("4", al.Configuration, "A4");
98 Assert.AreEqual ("5", al.Copyright, "A5");
99 Assert.AreEqual ("6", al.Culture, "A6");
100 Assert.AreEqual (true, al.DelaySign, "A7");
101 Assert.AreEqual ("7", al.Description, "A8");
102 Assert.AreEqual ("8", al.EmbedResources [0].ItemSpec, "A9");
103 Assert.AreEqual ("9", al.EvidenceFile, "A10");
104 Assert.AreEqual ("10", al.FileVersion, "A11");
105 Assert.AreEqual ("11", al.Flags, "A12");
106 Assert.AreEqual (true, al.GenerateFullPaths, "A13");
107 Assert.AreEqual ("12", al.KeyContainer, "A14");
108 Assert.AreEqual ("13", al.KeyFile, "A15");
109 Assert.AreEqual ("14", al.LinkResources [0].ItemSpec, "A16");
110 Assert.AreEqual ("15", al.MainEntryPoint, "A17");
111 Assert.AreEqual ("16", al.OutputAssembly.ItemSpec, "A18");
112 Assert.AreEqual ("17", al.Platform, "A19");
113 Assert.AreEqual ("18", al.ProductName, "A20");
114 Assert.AreEqual ("19", al.ProductVersion, "A21");
115 Assert.AreEqual ("20", al.ResponseFiles [0], "A22");
116 Assert.AreEqual ("21", al.SourceModules [0].ItemSpec, "A23");
117 Assert.AreEqual ("22", al.TargetType, "A24");
118 Assert.AreEqual ("23", al.TemplateFile, "A25");
119 Assert.AreEqual ("24", al.Title, "A26");
120 Assert.AreEqual ("25", al.Trademark, "A27");
121 Assert.AreEqual ("26", al.Version, "A28");
122 Assert.AreEqual ("27", al.Win32Icon, "A29");
123 Assert.AreEqual ("28", al.Win32Resource, "A30");
127 [Category ("NotWorking")]
128 public void TestAssignment2 ()
130 ALExtended ale = new ALExtended ();
131 Assert.AreEqual ("AL.exe", ale.TN, "A31");
135 public void TestDefaultValues ()
139 Assert.IsNull (al.AlgorithmId, "A1");
140 Assert.IsNull (al.BaseAddress, "A2");
141 Assert.IsNull (al.CompanyName, "A3");
142 Assert.IsNull (al.Configuration, "A4");
143 Assert.IsNull (al.Copyright, "A5");
144 Assert.IsNull (al.Culture, "A6");
145 Assert.IsFalse (al.DelaySign, "A7");
146 Assert.IsNull (al.Description, "A8");
147 Assert.IsNull (al.EmbedResources, "A9");
148 Assert.IsNull (al.EvidenceFile, "A10");
149 Assert.IsNull (al.FileVersion, "A11");
150 Assert.IsNull (al.Flags, "A12");
151 Assert.IsFalse (al.GenerateFullPaths, "A13");
152 Assert.IsNull (al.KeyContainer, "A14");
153 Assert.IsNull (al.KeyFile, "A15");
154 Assert.IsNull (al.LinkResources, "A16");
155 Assert.IsNull (al.MainEntryPoint, "A17");
156 Assert.IsNull (al.OutputAssembly, "A18");
157 Assert.IsNull (al.Platform, "A19");
158 Assert.IsNull (al.ProductName, "A20");
159 Assert.IsNull (al.ProductVersion, "A21");
160 Assert.IsNull (al.ResponseFiles, "A22");
161 Assert.IsNull (al.SourceModules, "A23");
162 Assert.IsNull (al.TargetType, "A24");
163 Assert.IsNull (al.TemplateFile, "A25");
164 Assert.IsNull (al.Title, "A26");
165 Assert.IsNull (al.Trademark, "A27");
166 Assert.IsNull (al.Version, "A28");
167 Assert.IsNull (al.Win32Icon, "A29");
168 Assert.IsNull (al.Win32Resource, "A30");
172 public void TestAlgorithmId ()
174 ALExtended ale = new ALExtended ();
175 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
177 ale.AlgorithmId = "a";
180 Assert.AreEqual ("/algid:a", clbe.ToString (), "A1");
184 public void TestBaseAddress ()
186 ALExtended ale = new ALExtended ();
187 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
189 ale.BaseAddress = "a";
192 Assert.AreEqual ("/baseaddress:a", clbe.ToString (), "A1");
196 public void TestCompanyName ()
198 ALExtended ale = new ALExtended ();
199 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
201 ale.CompanyName = "a";
204 Assert.AreEqual ("/company:a", clbe.ToString (), "A1");
208 public void TestConfiguration ()
210 ALExtended ale = new ALExtended ();
211 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
213 ale.Configuration = "a";
216 Assert.AreEqual ("/configuration:a", clbe.ToString (), "A1");
220 public void TestCopyright ()
222 ALExtended ale = new ALExtended ();
223 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
228 Assert.AreEqual ("/copyright:a", clbe.ToString (), "A1");
232 public void TestCulture ()
234 ALExtended ale = new ALExtended ();
235 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
240 Assert.AreEqual ("/culture:a", clbe.ToString (), "A1");
244 public void TestDelaySign1 ()
246 ALExtended ale = new ALExtended ();
247 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
249 ale.DelaySign = true;
252 Assert.AreEqual ("/delaysign+", clbe.ToString (), "A1");
256 public void TestDelaySign2 ()
258 ALExtended ale = new ALExtended ();
259 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
261 ale.DelaySign = false;
264 Assert.AreEqual ("/delaysign-", clbe.ToString (), "A1");
268 public void TestDescription ()
270 ALExtended ale = new ALExtended ();
271 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
273 ale.Description = "a";
276 Assert.AreEqual ("/description:a", clbe.ToString (), "A1");
280 public void TestEmbedResources ()
282 ALExtended ale = new ALExtended ();
283 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
285 ale.EmbedResources = new ITaskItem [2] { new TaskItem ("a"), new TaskItem ("b") };
288 Assert.AreEqual ("/embed:a /embed:b", clbe.ToString (), "A1");
292 public void TestEmbedResourcesWithLogicalName ()
294 ALExtended ale = new ALExtended ();
295 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
296 var dict = new Dictionary<string, string> ();
297 dict ["LogicalName"] = "value";
299 ale.EmbedResources = new ITaskItem [2] { new TaskItem ("a", dict), new TaskItem ("b", dict) };
302 Assert.AreEqual ("/embed:a,value /embed:b,value", clbe.ToString (), "A1");
306 public void TestEvidenceFile ()
308 ALExtended ale = new ALExtended ();
309 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
311 ale.EvidenceFile = "a";
314 Assert.AreEqual ("/evidence:a", clbe.ToString (), "A1");
318 public void TestFileVersion ()
320 ALExtended ale = new ALExtended ();
321 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
323 ale.FileVersion = "a";
326 Assert.AreEqual ("/fileversion:a", clbe.ToString (), "A1");
330 public void TestFlags ()
332 ALExtended ale = new ALExtended ();
333 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
338 Assert.AreEqual ("/flags:a", clbe.ToString (), "A1");
342 public void TestGenerateFullPaths1 ()
344 ALExtended ale = new ALExtended ();
345 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
347 ale.GenerateFullPaths = true;
350 Assert.AreEqual ("/fullpaths", clbe.ToString (), "A1");
354 public void TestGenerateFullPaths2 ()
356 ALExtended ale = new ALExtended ();
357 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
359 ale.GenerateFullPaths = false;
362 Assert.AreEqual (String.Empty, clbe.ToString (), "A1");
366 public void TestKeyContainer ()
368 ALExtended ale = new ALExtended ();
369 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
371 ale.KeyContainer = "a";
374 Assert.AreEqual ("/keyname:a", clbe.ToString (), "A1");
378 public void TestKeyFile ()
380 ALExtended ale = new ALExtended ();
381 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
386 Assert.AreEqual ("/keyfile:a", clbe.ToString (), "A1");
390 public void TestLinkResources ()
392 ALExtended ale = new ALExtended ();
393 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
395 ale.LinkResources = new ITaskItem [2] { new TaskItem ("a"), new TaskItem ("b") };
398 Assert.AreEqual ("/link:a /link:b", clbe.ToString (), "A1");
402 public void TestMainEntryPoint ()
404 ALExtended ale = new ALExtended ();
405 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
407 ale.MainEntryPoint = "a";
410 Assert.AreEqual ("/main:a", clbe.ToString (), "A1");
414 public void TestOutputAssembly ()
416 ALExtended ale = new ALExtended ();
417 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
419 ale.OutputAssembly = new TaskItem ("a");
422 Assert.AreEqual ("/out:a", clbe.ToString (), "A1");
426 [Category ("NotWorking")]
427 public void TestPlatform ()
429 ALExtended ale = new ALExtended ();
430 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
435 Assert.AreEqual ("/platform:a", clbe.ToString (), "A1");
439 public void TestProductName ()
441 ALExtended ale = new ALExtended ();
442 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
444 ale.ProductName = "a";
447 Assert.AreEqual ("/product:a", clbe.ToString (), "A1");
451 public void TestProductVersion ()
453 ALExtended ale = new ALExtended ();
454 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
456 ale.ProductVersion = "a";
459 Assert.AreEqual ("/productversion:a", clbe.ToString (), "A1");
463 public void TestResponseFiles ()
465 ALExtended ale = new ALExtended ();
466 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
468 ale.ResponseFiles = new string [2] { "a", "b" };
471 Assert.AreEqual ("@a @b", clbe.ToString (), "A1");
475 public void TestSourceModules ()
477 ALExtended ale = new ALExtended ();
478 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
480 ale.SourceModules = new ITaskItem [2] { new TaskItem ("a"), new TaskItem ("b") };
483 Assert.AreEqual ("a b", clbe.ToString (), "A1");
487 public void TestTargetType ()
489 ALExtended ale = new ALExtended ();
490 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
492 ale.TargetType = "a";
495 Assert.AreEqual ("/target:a", clbe.ToString (), "A1");
499 public void TestTemplateFile ()
501 ALExtended ale = new ALExtended ();
502 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
504 ale.TemplateFile = "a";
507 Assert.AreEqual ("/template:a", clbe.ToString (), "A1");
511 public void TestTitle ()
513 ALExtended ale = new ALExtended ();
514 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
519 Assert.AreEqual ("/title:a", clbe.ToString (), "A1");
523 public void TestTrademark ()
525 ALExtended ale = new ALExtended ();
526 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
531 Assert.AreEqual ("/trademark:a", clbe.ToString (), "A1");
535 public void TestVersion ()
537 ALExtended ale = new ALExtended ();
538 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
543 Assert.AreEqual ("/version:a", clbe.ToString (), "A1");
547 public void TestWin32Icon ()
549 ALExtended ale = new ALExtended ();
550 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
555 Assert.AreEqual ("/win32icon:a", clbe.ToString (), "A1");
559 public void TestWin32Resource ()
561 ALExtended ale = new ALExtended ();
562 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
564 ale.Win32Resource = "a";
567 Assert.AreEqual ("/win32res:a", clbe.ToString (), "A1");