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