Merge pull request #1067 from esdrubal/bug19862
[mono.git] / mcs / class / Microsoft.Build.Tasks / Test / Microsoft.Build.Tasks / ALTest.cs
1 //
2 // ALTest.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.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;
36
37 namespace MonoTests.Microsoft.Build.Tasks {
38
39         class ALExtended : AL {
40                 public ALExtended ()
41                         : base ()
42                 {
43                 }
44
45                 public void ARFC (CommandLineBuilderExtension commandLine)
46                 {
47                         base.AddResponseFileCommands (commandLine);
48                 }
49
50                 public string TN {
51                         get { return base.ToolName; }
52                 }
53         }
54
55         [TestFixture]
56         public class ALTest {
57                 
58                 [Test]
59                 public void TestAssignment1 ()
60                 {
61                         AL al = new AL ();
62
63                         al.AlgorithmId = "1";
64                         al.BaseAddress = "2";
65                         al.CompanyName = "3";
66                         al.Configuration = "4";
67                         al.Copyright = "5";
68                         al.Culture = "6";
69                         al.DelaySign = true;
70                         al.Description = "7";
71                         al.EmbedResources = new ITaskItem [1] { new TaskItem ("8") };
72                         al.EvidenceFile = "9";
73                         al.FileVersion = "10";
74                         al.Flags = "11";
75                         al.GenerateFullPaths = true;
76                         al.KeyContainer = "12";
77                         al.KeyFile = "13";
78                         al.LinkResources = new ITaskItem [1] { new TaskItem ("14") };
79                         al.MainEntryPoint = "15";
80                         al.OutputAssembly = new TaskItem ("16");
81                         al.Platform = "17";
82                         al.ProductName = "18";
83                         al.ProductVersion = "19";
84                         al.ResponseFiles = new string [1] { "20" };
85                         al.SourceModules = new ITaskItem [1] { new TaskItem ("21") };
86                         al.TargetType = "22";
87                         al.TemplateFile = "23";
88                         al.Title = "24";
89                         al.Trademark = "25";
90                         al.Version = "26";
91                         al.Win32Icon = "27";
92                         al.Win32Resource = "28";
93
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");
124                 }
125
126                 [Test]
127                 [Category ("NotWorking")]
128                 public void TestAssignment2 ()
129                 {
130                         ALExtended ale = new ALExtended ();
131                         Assert.AreEqual ("AL.exe", ale.TN, "A31");
132                 }
133
134                 [Test]
135                 public void TestDefaultValues ()
136                 {
137                         AL al = new AL ();
138
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");
169                 }
170
171                 [Test]
172                 public void TestAlgorithmId ()
173                 {
174                         ALExtended ale = new ALExtended ();
175                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
176
177                         ale.AlgorithmId = "a";
178                         ale.ARFC (clbe);
179                         
180                         Assert.AreEqual ("/algid:a", clbe.ToString (), "A1");
181                 }
182
183                 [Test]
184                 public void TestBaseAddress ()
185                 {
186                         ALExtended ale = new ALExtended ();
187                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
188
189                         ale.BaseAddress = "a";
190                         ale.ARFC (clbe);
191                         
192                         Assert.AreEqual ("/baseaddress:a", clbe.ToString (), "A1");
193                 }
194
195                 [Test]
196                 public void TestCompanyName ()
197                 {
198                         ALExtended ale = new ALExtended ();
199                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
200
201                         ale.CompanyName = "a";
202                         ale.ARFC (clbe);
203                         
204                         Assert.AreEqual ("/company:a", clbe.ToString (), "A1");
205                 }
206
207                 [Test]
208                 public void TestConfiguration ()
209                 {
210                         ALExtended ale = new ALExtended ();
211                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
212
213                         ale.Configuration = "a";
214                         ale.ARFC (clbe);
215                         
216                         Assert.AreEqual ("/configuration:a", clbe.ToString (), "A1");
217                 }
218
219                 [Test]
220                 public void TestCopyright ()
221                 {
222                         ALExtended ale = new ALExtended ();
223                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
224
225                         ale.Copyright = "a";
226                         ale.ARFC (clbe);
227                         
228                         Assert.AreEqual ("/copyright:a", clbe.ToString (), "A1");
229                 }
230
231                 [Test]
232                 public void TestCulture ()
233                 {
234                         ALExtended ale = new ALExtended ();
235                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
236
237                         ale.Culture = "a";
238                         ale.ARFC (clbe);
239                         
240                         Assert.AreEqual ("/culture:a", clbe.ToString (), "A1");
241                 }
242
243                 [Test]
244                 public void TestDelaySign1 ()
245                 {
246                         ALExtended ale = new ALExtended ();
247                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
248
249                         ale.DelaySign = true;
250                         ale.ARFC (clbe);
251                         
252                         Assert.AreEqual ("/delaysign+", clbe.ToString (), "A1");
253                 }
254
255                 [Test]
256                 public void TestDelaySign2 ()
257                 {
258                         ALExtended ale = new ALExtended ();
259                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
260
261                         ale.DelaySign = false;
262                         ale.ARFC (clbe);
263                         
264                         Assert.AreEqual ("/delaysign-", clbe.ToString (), "A1");
265                 }
266
267                 [Test]
268                 public void TestDescription ()
269                 {
270                         ALExtended ale = new ALExtended ();
271                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
272
273                         ale.Description = "a";
274                         ale.ARFC (clbe);
275                         
276                         Assert.AreEqual ("/description:a", clbe.ToString (), "A1");
277                 }
278
279                 [Test]
280                 public void TestEmbedResources ()
281                 {
282                         ALExtended ale = new ALExtended ();
283                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
284
285                         ale.EmbedResources = new ITaskItem [2] { new TaskItem ("a"), new TaskItem ("b") };
286                         ale.ARFC (clbe);
287                         
288                         Assert.AreEqual ("/embed:a /embed:b", clbe.ToString (), "A1");
289                 }
290
291                 [Test]
292                 public void TestEmbedResourcesWithLogicalName ()
293                 {
294                         ALExtended ale = new ALExtended ();
295                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
296                         var dict = new Dictionary<string, string> ();
297                         dict ["LogicalName"] = "value";
298
299                         ale.EmbedResources = new ITaskItem [2] { new TaskItem ("a", dict), new TaskItem ("b", dict) };
300                         ale.ARFC (clbe);
301
302                         Assert.AreEqual ("/embed:a,value /embed:b,value", clbe.ToString (), "A1");
303                 }
304
305                 [Test]
306                 public void TestEvidenceFile ()
307                 {
308                         ALExtended ale = new ALExtended ();
309                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
310
311                         ale.EvidenceFile = "a";
312                         ale.ARFC (clbe);
313                         
314                         Assert.AreEqual ("/evidence:a", clbe.ToString (), "A1");
315                 }
316
317                 [Test]
318                 public void TestFileVersion ()
319                 {
320                         ALExtended ale = new ALExtended ();
321                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
322
323                         ale.FileVersion = "a";
324                         ale.ARFC (clbe);
325                         
326                         Assert.AreEqual ("/fileversion:a", clbe.ToString (), "A1");
327                 }
328
329                 [Test]
330                 public void TestFlags ()
331                 {
332                         ALExtended ale = new ALExtended ();
333                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
334
335                         ale.Flags = "a";
336                         ale.ARFC (clbe);
337                         
338                         Assert.AreEqual ("/flags:a", clbe.ToString (), "A1");
339                 }
340
341                 [Test]
342                 public void TestGenerateFullPaths1 ()
343                 {
344                         ALExtended ale = new ALExtended ();
345                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
346
347                         ale.GenerateFullPaths = true;
348                         ale.ARFC (clbe);
349                         
350                         Assert.AreEqual ("/fullpaths", clbe.ToString (), "A1");
351                 }
352
353                 [Test]
354                 public void TestGenerateFullPaths2 ()
355                 {
356                         ALExtended ale = new ALExtended ();
357                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
358
359                         ale.GenerateFullPaths = false;
360                         ale.ARFC (clbe);
361                         
362                         Assert.AreEqual (String.Empty, clbe.ToString (), "A1");
363                 }
364
365                 [Test]
366                 public void TestKeyContainer ()
367                 {
368                         ALExtended ale = new ALExtended ();
369                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
370
371                         ale.KeyContainer = "a";
372                         ale.ARFC (clbe);
373                         
374                         Assert.AreEqual ("/keyname:a", clbe.ToString (), "A1");
375                 }
376
377                 [Test]
378                 public void TestKeyFile ()
379                 {
380                         ALExtended ale = new ALExtended ();
381                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
382
383                         ale.KeyFile = "a";
384                         ale.ARFC (clbe);
385                         
386                         Assert.AreEqual ("/keyfile:a", clbe.ToString (), "A1");
387                 }
388
389                 [Test]
390                 public void TestLinkResources ()
391                 {
392                         ALExtended ale = new ALExtended ();
393                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
394
395                         ale.LinkResources = new ITaskItem [2] { new TaskItem ("a"), new TaskItem ("b") };
396                         ale.ARFC (clbe);
397                         
398                         Assert.AreEqual ("/link:a /link:b", clbe.ToString (), "A1");
399                 }
400
401                 [Test]
402                 public void TestMainEntryPoint ()
403                 {
404                         ALExtended ale = new ALExtended ();
405                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
406
407                         ale.MainEntryPoint = "a";
408                         ale.ARFC (clbe);
409                         
410                         Assert.AreEqual ("/main:a", clbe.ToString (), "A1");
411                 }
412
413                 [Test]
414                 public void TestOutputAssembly ()
415                 {
416                         ALExtended ale = new ALExtended ();
417                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
418
419                         ale.OutputAssembly = new TaskItem ("a");
420                         ale.ARFC (clbe);
421                         
422                         Assert.AreEqual ("/out:a", clbe.ToString (), "A1");
423                 }
424
425                 [Test]
426                 [Category ("NotWorking")]
427                 public void TestPlatform ()
428                 {
429                         ALExtended ale = new ALExtended ();
430                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
431
432                         ale.Platform = "a";
433                         ale.ARFC (clbe);
434                         
435                         Assert.AreEqual ("/platform:a", clbe.ToString (), "A1");
436                 }
437
438                 [Test]
439                 public void TestProductName ()
440                 {
441                         ALExtended ale = new ALExtended ();
442                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
443
444                         ale.ProductName = "a";
445                         ale.ARFC (clbe);
446                         
447                         Assert.AreEqual ("/product:a", clbe.ToString (), "A1");
448                 }
449
450                 [Test]
451                 public void TestProductVersion ()
452                 {
453                         ALExtended ale = new ALExtended ();
454                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
455
456                         ale.ProductVersion = "a";
457                         ale.ARFC (clbe);
458                         
459                         Assert.AreEqual ("/productversion:a", clbe.ToString (), "A1");
460                 }
461
462                 [Test]
463                 public void TestResponseFiles ()
464                 {
465                         ALExtended ale = new ALExtended ();
466                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
467
468                         ale.ResponseFiles = new string [2] { "a", "b" };
469                         ale.ARFC (clbe);
470                         
471                         Assert.AreEqual ("@a @b", clbe.ToString (), "A1");
472                 }
473
474                 [Test]
475                 public void TestSourceModules ()
476                 {
477                         ALExtended ale = new ALExtended ();
478                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
479
480                         ale.SourceModules = new ITaskItem [2] { new TaskItem ("a"), new TaskItem ("b") };
481                         ale.ARFC (clbe);
482                         
483                         Assert.AreEqual ("a b", clbe.ToString (), "A1");
484                 }
485
486                 [Test]
487                 public void TestTargetType ()
488                 {
489                         ALExtended ale = new ALExtended ();
490                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
491
492                         ale.TargetType = "a";
493                         ale.ARFC (clbe);
494                         
495                         Assert.AreEqual ("/target:a", clbe.ToString (), "A1");
496                 }
497
498                 [Test]
499                 public void TestTemplateFile ()
500                 {
501                         ALExtended ale = new ALExtended ();
502                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
503
504                         ale.TemplateFile = "a";
505                         ale.ARFC (clbe);
506                         
507                         Assert.AreEqual ("/template:a", clbe.ToString (), "A1");
508                 }
509
510                 [Test]
511                 public void TestTitle ()
512                 {
513                         ALExtended ale = new ALExtended ();
514                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
515
516                         ale.Title = "a";
517                         ale.ARFC (clbe);
518                         
519                         Assert.AreEqual ("/title:a", clbe.ToString (), "A1");
520                 }
521
522                 [Test]
523                 public void TestTrademark ()
524                 {
525                         ALExtended ale = new ALExtended ();
526                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
527
528                         ale.Trademark = "a";
529                         ale.ARFC (clbe);
530                         
531                         Assert.AreEqual ("/trademark:a", clbe.ToString (), "A1");
532                 }
533
534                 [Test]
535                 public void TestVersion ()
536                 {
537                         ALExtended ale = new ALExtended ();
538                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
539
540                         ale.Version = "a";
541                         ale.ARFC (clbe);
542                         
543                         Assert.AreEqual ("/version:a", clbe.ToString (), "A1");
544                 }
545
546                 [Test]
547                 public void TestWin32Icon ()
548                 {
549                         ALExtended ale = new ALExtended ();
550                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
551
552                         ale.Win32Icon = "a";
553                         ale.ARFC (clbe);
554                         
555                         Assert.AreEqual ("/win32icon:a", clbe.ToString (), "A1");
556                 }
557
558                 [Test]
559                 public void TestWin32Resource ()
560                 {
561                         ALExtended ale = new ALExtended ();
562                         CommandLineBuilderExtension clbe = new CommandLineBuilderExtension ();
563
564                         ale.Win32Resource = "a";
565                         ale.ARFC (clbe);
566                         
567                         Assert.AreEqual ("/win32res:a", clbe.ToString (), "A1");
568                 }
569         }
570 }
571