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 Microsoft.Build.BuildEngine;
31 using Microsoft.Build.Framework;
32 using Microsoft.Build.Tasks;
33 using Microsoft.Build.Utilities;
34 using NUnit.Framework;
36 namespace MonoTests.Microsoft.Build.Tasks {
38 class ALExtended : AL {
44 public void ARFC (CommandLineBuilderExtension commandLine)
46 base.AddResponseFileCommands (commandLine);
50 get { return base.ToolName; }
58 public void TestAssignment1 ()
65 al.Configuration = "4";
70 al.EmbedResources = new ITaskItem [1] { new TaskItem ("8") };
71 al.EvidenceFile = "9";
72 al.FileVersion = "10";
74 al.GenerateFullPaths = true;
75 al.KeyContainer = "12";
77 al.LinkResources = new ITaskItem [1] { new TaskItem ("14") };
78 al.MainEntryPoint = "15";
79 al.OutputAssembly = new TaskItem ("16");
81 al.ProductName = "18";
82 al.ProductVersion = "19";
83 al.ResponseFiles = new string [1] { "20" };
84 al.SourceModules = new ITaskItem [1] { new TaskItem ("21") };
86 al.TemplateFile = "23";
91 al.Win32Resource = "28";
93 Assert.AreEqual ("1", al.AlgorithmId, "A1");
94 Assert.AreEqual ("2", al.BaseAddress, "A2");
95 Assert.AreEqual ("3", al.CompanyName, "A3");
96 Assert.AreEqual ("4", al.Configuration, "A4");
97 Assert.AreEqual ("5", al.Copyright, "A5");
98 Assert.AreEqual ("6", al.Culture, "A6");
99 Assert.AreEqual (true, al.DelaySign, "A7");
100 Assert.AreEqual ("7", al.Description, "A8");
101 Assert.AreEqual ("8", al.EmbedResources [0].ItemSpec, "A9");
102 Assert.AreEqual ("9", al.EvidenceFile, "A10");
103 Assert.AreEqual ("10", al.FileVersion, "A11");
104 Assert.AreEqual ("11", al.Flags, "A12");
105 Assert.AreEqual (true, al.GenerateFullPaths, "A13");
106 Assert.AreEqual ("12", al.KeyContainer, "A14");
107 Assert.AreEqual ("13", al.KeyFile, "A15");
108 Assert.AreEqual ("14", al.LinkResources [0].ItemSpec, "A16");
109 Assert.AreEqual ("15", al.MainEntryPoint, "A17");
110 Assert.AreEqual ("16", al.OutputAssembly.ItemSpec, "A18");
111 Assert.AreEqual ("17", al.Platform, "A19");
112 Assert.AreEqual ("18", al.ProductName, "A20");
113 Assert.AreEqual ("19", al.ProductVersion, "A21");
114 Assert.AreEqual ("20", al.ResponseFiles [0], "A22");
115 Assert.AreEqual ("21", al.SourceModules [0].ItemSpec, "A23");
116 Assert.AreEqual ("22", al.TargetType, "A24");
117 Assert.AreEqual ("23", al.TemplateFile, "A25");
118 Assert.AreEqual ("24", al.Title, "A26");
119 Assert.AreEqual ("25", al.Trademark, "A27");
120 Assert.AreEqual ("26", al.Version, "A28");
121 Assert.AreEqual ("27", al.Win32Icon, "A29");
122 Assert.AreEqual ("28", al.Win32Resource, "A30");
126 [Category ("NotWorking")]
127 public void TestAssignment2 ()
129 ALExtended ale = new ALExtended ();
130 Assert.AreEqual ("AL.exe", ale.TN, "A31");
134 public void TestDefaultValues ()
138 Assert.IsNull (al.AlgorithmId, "A1");
139 Assert.IsNull (al.BaseAddress, "A2");
140 Assert.IsNull (al.CompanyName, "A3");
141 Assert.IsNull (al.Configuration, "A4");
142 Assert.IsNull (al.Copyright, "A5");
143 Assert.IsNull (al.Culture, "A6");
144 Assert.IsFalse (al.DelaySign, "A7");
145 Assert.IsNull (al.Description, "A8");
146 Assert.IsNull (al.EmbedResources, "A9");
147 Assert.IsNull (al.EvidenceFile, "A10");
148 Assert.IsNull (al.FileVersion, "A11");
149 Assert.IsNull (al.Flags, "A12");
150 Assert.IsFalse (al.GenerateFullPaths, "A13");
151 Assert.IsNull (al.KeyContainer, "A14");
152 Assert.IsNull (al.KeyFile, "A15");
153 Assert.IsNull (al.LinkResources, "A16");
154 Assert.IsNull (al.MainEntryPoint, "A17");
155 Assert.IsNull (al.OutputAssembly, "A18");
156 Assert.IsNull (al.Platform, "A19");
157 Assert.IsNull (al.ProductName, "A20");
158 Assert.IsNull (al.ProductVersion, "A21");
159 Assert.IsNull (al.ResponseFiles, "A22");
160 Assert.IsNull (al.SourceModules, "A23");
161 Assert.IsNull (al.TargetType, "A24");
162 Assert.IsNull (al.TemplateFile, "A25");
163 Assert.IsNull (al.Title, "A26");
164 Assert.IsNull (al.Trademark, "A27");
165 Assert.IsNull (al.Version, "A28");
166 Assert.IsNull (al.Win32Icon, "A29");
167 Assert.IsNull (al.Win32Resource, "A30");
171 public void TestAlgorithmId ()
173 ALExtended ale = new ALExtended ();
174 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
176 ale.AlgorithmId = "a";
179 Assert.AreEqual ("/algid:a", clbe.ToString (), "A1");
183 public void TestBaseAddress ()
185 ALExtended ale = new ALExtended ();
186 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
188 ale.BaseAddress = "a";
191 Assert.AreEqual ("/baseaddress:a", clbe.ToString (), "A1");
195 public void TestCompanyName ()
197 ALExtended ale = new ALExtended ();
198 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
200 ale.CompanyName = "a";
203 Assert.AreEqual ("/company:a", clbe.ToString (), "A1");
207 public void TestConfiguration ()
209 ALExtended ale = new ALExtended ();
210 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
212 ale.Configuration = "a";
215 Assert.AreEqual ("/configuration:a", clbe.ToString (), "A1");
219 public void TestCopyright ()
221 ALExtended ale = new ALExtended ();
222 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
227 Assert.AreEqual ("/copyright:a", clbe.ToString (), "A1");
231 public void TestCulture ()
233 ALExtended ale = new ALExtended ();
234 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
239 Assert.AreEqual ("/culture:a", clbe.ToString (), "A1");
243 public void TestDelaySign1 ()
245 ALExtended ale = new ALExtended ();
246 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
248 ale.DelaySign = true;
251 Assert.AreEqual ("/delaysign+", clbe.ToString (), "A1");
255 public void TestDelaySign2 ()
257 ALExtended ale = new ALExtended ();
258 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
260 ale.DelaySign = false;
263 Assert.AreEqual ("/delaysign-", clbe.ToString (), "A1");
267 public void TestDescription ()
269 ALExtended ale = new ALExtended ();
270 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
272 ale.Description = "a";
275 Assert.AreEqual ("/description:a", clbe.ToString (), "A1");
279 public void TestEmbedResources ()
281 ALExtended ale = new ALExtended ();
282 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
284 ale.EmbedResources = new ITaskItem [2] { new TaskItem ("a"), new TaskItem ("b") };
287 Assert.AreEqual ("/embed:a /embed:b", clbe.ToString (), "A1");
291 public void TestEvidenceFile ()
293 ALExtended ale = new ALExtended ();
294 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
296 ale.EvidenceFile = "a";
299 Assert.AreEqual ("/evidence:a", clbe.ToString (), "A1");
303 public void TestFileVersion ()
305 ALExtended ale = new ALExtended ();
306 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
308 ale.FileVersion = "a";
311 Assert.AreEqual ("/fileversion:a", clbe.ToString (), "A1");
315 public void TestFlags ()
317 ALExtended ale = new ALExtended ();
318 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
323 Assert.AreEqual ("/flags:a", clbe.ToString (), "A1");
327 public void TestGenerateFullPaths1 ()
329 ALExtended ale = new ALExtended ();
330 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
332 ale.GenerateFullPaths = true;
335 Assert.AreEqual ("/fullpaths", clbe.ToString (), "A1");
339 public void TestGenerateFullPaths2 ()
341 ALExtended ale = new ALExtended ();
342 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
344 ale.GenerateFullPaths = false;
347 Assert.AreEqual (String.Empty, clbe.ToString (), "A1");
351 public void TestKeyContainer ()
353 ALExtended ale = new ALExtended ();
354 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
356 ale.KeyContainer = "a";
359 Assert.AreEqual ("/keyname:a", clbe.ToString (), "A1");
363 public void TestKeyFile ()
365 ALExtended ale = new ALExtended ();
366 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
371 Assert.AreEqual ("/keyfile:a", clbe.ToString (), "A1");
375 public void TestLinkResources ()
377 ALExtended ale = new ALExtended ();
378 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
380 ale.LinkResources = new ITaskItem [2] { new TaskItem ("a"), new TaskItem ("b") };
383 Assert.AreEqual ("/link:a /link:b", clbe.ToString (), "A1");
387 public void TestMainEntryPoint ()
389 ALExtended ale = new ALExtended ();
390 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
392 ale.MainEntryPoint = "a";
395 Assert.AreEqual ("/main:a", clbe.ToString (), "A1");
399 public void TestOutputAssembly ()
401 ALExtended ale = new ALExtended ();
402 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
404 ale.OutputAssembly = new TaskItem ("a");
407 Assert.AreEqual ("/out:a", clbe.ToString (), "A1");
411 [Category ("NotWorking")]
412 public void TestPlatform ()
414 ALExtended ale = new ALExtended ();
415 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
420 Assert.AreEqual ("/platform:a", clbe.ToString (), "A1");
424 public void TestProductName ()
426 ALExtended ale = new ALExtended ();
427 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
429 ale.ProductName = "a";
432 Assert.AreEqual ("/product:a", clbe.ToString (), "A1");
436 public void TestProductVersion ()
438 ALExtended ale = new ALExtended ();
439 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
441 ale.ProductVersion = "a";
444 Assert.AreEqual ("/productversion:a", clbe.ToString (), "A1");
448 public void TestResponseFiles ()
450 ALExtended ale = new ALExtended ();
451 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
453 ale.ResponseFiles = new string [2] { "a", "b" };
456 Assert.AreEqual ("@a @b", clbe.ToString (), "A1");
460 public void TestSourceModules ()
462 ALExtended ale = new ALExtended ();
463 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
465 ale.SourceModules = new ITaskItem [2] { new TaskItem ("a"), new TaskItem ("b") };
468 Assert.AreEqual ("a b", clbe.ToString (), "A1");
472 public void TestTargetType ()
474 ALExtended ale = new ALExtended ();
475 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
477 ale.TargetType = "a";
480 Assert.AreEqual ("/target:a", clbe.ToString (), "A1");
484 public void TestTemplateFile ()
486 ALExtended ale = new ALExtended ();
487 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
489 ale.TemplateFile = "a";
492 Assert.AreEqual ("/template:a", clbe.ToString (), "A1");
496 public void TestTitle ()
498 ALExtended ale = new ALExtended ();
499 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
504 Assert.AreEqual ("/title:a", clbe.ToString (), "A1");
508 public void TestTrademark ()
510 ALExtended ale = new ALExtended ();
511 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
516 Assert.AreEqual ("/trademark:a", clbe.ToString (), "A1");
520 public void TestVersion ()
522 ALExtended ale = new ALExtended ();
523 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
528 Assert.AreEqual ("/version:a", clbe.ToString (), "A1");
532 public void TestWin32Icon ()
534 ALExtended ale = new ALExtended ();
535 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
540 Assert.AreEqual ("/win32icon:a", clbe.ToString (), "A1");
544 public void TestWin32Resource ()
546 ALExtended ale = new ALExtended ();
547 CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
549 ale.Win32Resource = "a";
552 Assert.AreEqual ("/win32res:a", clbe.ToString (), "A1");