forked from microsoft/TemplateStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseGenAndBuildTests.cs
More file actions
614 lines (491 loc) · 28.4 KB
/
BaseGenAndBuildTests.cs
File metadata and controls
614 lines (491 loc) · 28.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Templates.Core;
using Microsoft.Templates.Core.Gen;
using Microsoft.TemplateEngine.Abstractions;
using Xunit;
using Microsoft.Templates.Fakes;
using Microsoft.Templates.Core.Helpers;
using Microsoft.Templates.Core.Extensions;
using Microsoft.Templates.Core.Naming;
using Microsoft.Templates.UI.Services;
using Microsoft.Templates.Test.BuildWithLegacy;
namespace Microsoft.Templates.Test
{
public class BaseGenAndBuildTests
{
protected BaseGenAndBuildFixture _fixture;
private readonly string _emptyBackendFramework = string.Empty;
protected const string All = "all";
protected List<string> excludedTemplates_Uwp_Group1 = new List<string>() { "wts.Service.IdentityOptionalLogin", "wts.Feat.MultiInstanceAdvanced", "wts.Feat.MultiInstance" };
protected List<string> excludedTemplates_Uwp_Group2 = new List<string>() { "wts.Service.IdentityForcedLogin", "wts.Feat.BackgroundTask" }; // Add multiinstance templates on this group if possible
protected List<string> excludedTemplates_Wpf_Group1 = new List<string>() { "wts.Wpf.Service.IdentityOptionalLogin" };
protected List<string> excludedTemplates_Wpf_Group2 = new List<string>() { "wts.Wpf.Service.IdentityForcedLogin" }; // Add multiinstance templates on this group if possible
protected List<string> excludedTemplatesGroup1VB = new List<string>() { "wts.Service.IdentityOptionalLogin.VB", "wts.Feat.MultiInstanceAdvanced.VB", "wts.Feat.MultiInstance.VB" };
protected List<string> excludedTemplatesGroup2VB = new List<string>() { "wts.Service.IdentityForcedLogin.VB", "wts.Feat.BackgroundTask.VB" }; // Add multiinstance templates on this group if possible
public BaseGenAndBuildTests(BaseGenAndBuildFixture fixture, IContextProvider contextProvider = null, string framework = "")
{
_fixture = fixture;
_fixture.InitializeFixture(contextProvider ?? new FakeContextProvider(), framework);
}
protected static string ShortLanguageName(string language)
{
return language == ProgrammingLanguages.CSharp ? "CS" : "VB";
}
// Used to create names that include a number of characters that are valid in project names but have the potential to cause issues
protected static string CharactersThatMayCauseProjectNameIssues()
{
// $ is technically valid in a project name but cannot be used with WTS as it is used as an identifier in global post action file names.
// ^ is technically valid in project names but Visual Studio cannot open files with this in the path
// ' is technically valid in project names but breaks test projects if used in the name so don't test for it
// , is technically valid in project names but breaks vb test projects in VS 2019 if used in the name so don't test for it
return " -_.@! (£)+=";
}
protected static string ShortProjectType(string projectType)
{
switch (projectType)
{
case "Blank":
return "B";
case "SplitView":
return "SV";
case "SplitViewWpf":
return "SVWpf";
case "TabbedNav":
return "TN";
case "MenuBar":
return "MB";
case "MenuBarWpf":
return "MBWpf";
case "Ribbon":
return "RB";
default:
return projectType;
}
}
protected static string GetProjectExtension(string language)
{
return language == ProgrammingLanguages.CSharp ? "csproj" : "vbproj";
}
protected async Task<(string projectName, string projectPath)> GenerateEmptyProjectAsync(string projectType, string framework, string platform, string language)
{
var projectName = $"{ShortProjectType(projectType)}Empty{ShortLanguageName(language)}";
var projectPath = await AssertGenerateProjectAsync(projectName, projectType, framework, platform, language, null, null);
return (projectName, projectPath);
}
protected async Task<(string projectName, string projectPath)> GenerateAllPagesAndFeaturesAsync(string projectType, string framework, string platform, string language)
{
// get first item from each exclusive selection group
var exclusiveSelectionGroups = GenContext.ToolBox.Repo.GetAll().Where(t =>
t.GetTemplateType().IsItemTemplate()
&& (t.GetProjectTypeList().Contains(projectType) || t.GetProjectTypeList().Contains(All))
&& (t.GetFrontEndFrameworkList().Contains(framework) || t.GetFrontEndFrameworkList().Contains(All))
&& t.GetPlatform() == platform
&& t.GetIsGroupExclusiveSelection()).GroupBy(t => t.GetGroup(), (key, g) => g.First());
// this selector excludes templates with exclusions
bool templateSelector(ITemplateInfo t) => t.GetTemplateType().IsItemTemplate()
&& (t.GetProjectTypeList().Contains(projectType) || t.GetProjectTypeList().Contains(All))
&& (t.GetFrontEndFrameworkList().Contains(framework) || t.GetFrontEndFrameworkList().Contains(All))
&& t.GetPlatform() == platform
&& t.GetExclusionsList().Count() == 0
&& (!t.GetIsGroupExclusiveSelection() || (t.GetIsGroupExclusiveSelection() && exclusiveSelectionGroups.Contains(t)))
&& !t.GetIsHidden();
var projectName = $"{ShortProjectType(projectType)}All{ShortLanguageName(language)}";
var projectPath = await AssertGenerateProjectAsync(projectName, projectType, framework, platform, language, templateSelector, BaseGenAndBuildFixture.GetDefaultName);
return (projectName, projectPath);
}
protected async Task<string> AssertGenerateProjectAsync(string projectName, string projectType, string framework, string platform, string language, Func<ITemplateInfo, bool> itemTemplatesSelector = null, Func<TemplateInfo, string> getName = null, bool includeMultipleInstances = false)
{
BaseGenAndBuildFixture.SetCurrentLanguage(language);
BaseGenAndBuildFixture.SetCurrentPlatform(platform);
var destinationPath = Path.Combine(_fixture.TestProjectsPath, projectName, projectName);
GenContext.Current = new FakeContextProvider
{
ProjectName = projectName,
DestinationPath = destinationPath,
GenerationOutputPath = destinationPath,
};
var userSelection = _fixture.SetupProject(projectType, framework, platform, language, getName);
if (getName != null && itemTemplatesSelector != null)
{
var itemTemplates = _fixture.Templates().Where(itemTemplatesSelector);
var itemsTemplateInfo = GenContext.ToolBox.Repo.GetTemplatesInfo(itemTemplates, platform, projectType, framework, _emptyBackendFramework);
_fixture.AddItems(userSelection, itemsTemplateInfo, getName, includeMultipleInstances);
}
await NewProjectGenController.Instance.UnsafeGenerateProjectAsync(userSelection);
var resultPath = Path.Combine(_fixture.TestProjectsPath, projectName);
// Assert
Assert.True(Directory.Exists(resultPath));
Assert.True(Directory.GetFiles(resultPath, "*.*", SearchOption.AllDirectories).Count() > 2);
if (platform == Platforms.Uwp)
{
AssertCorrectProjectConfigInfo(projectType, framework, platform);
}
return resultPath;
}
protected void EnsureCanInferConfigInfo(string projectType, string framework, string platform, string projectPath)
{
RemoveProjectConfigInfoFromProject();
AssertCorrectProjectConfigInfo(projectType, framework, platform);
AssertProjectConfigInfoRecreated(projectType, framework, platform);
Fs.SafeDeleteDirectory(projectPath);
}
protected void RemoveProjectConfigInfoFromProject()
{
var manifest = Path.Combine(GenContext.Current.DestinationPath, "Package.appxmanifest");
var lines = File.ReadAllLines(manifest);
var sb = new StringBuilder();
var fx = $"genTemplate:Item Name=\"framework\"";
var pt = $"genTemplate:Item Name=\"projectType\"";
foreach (var line in lines)
{
if (!line.Contains(fx) && !line.Contains(pt))
{
sb.AppendLine(line);
}
}
File.Delete(manifest);
File.WriteAllText(manifest, sb.ToString(), Encoding.UTF8);
}
protected void AssertCorrectProjectConfigInfo(string expectedProjectType, string expectedFramework, string expectedPlatform)
{
var info = ProjectConfigInfoService.ReadProjectConfiguration();
Assert.Equal(expectedProjectType, info.ProjectType);
Assert.Equal(expectedFramework, info.Framework);
Assert.Equal(expectedPlatform, info.Platform);
}
protected void AssertProjectConfigInfoRecreated(string projectType, string framework, string platform)
{
var content = File.ReadAllText(Path.Combine(GenContext.Current.DestinationPath, "Package.appxmanifest"));
var expectedFxText = $"Name=\"framework\" Value=\"{framework}\"";
var expectedPtText = $"Name=\"projectType\" Value=\"{projectType}\"";
var expectedPfText = $"Name=\"platform\" Value=\"{platform}\"";
Assert.Contains(expectedFxText, content, StringComparison.OrdinalIgnoreCase);
Assert.Contains(expectedPtText, content, StringComparison.OrdinalIgnoreCase);
Assert.Contains(expectedPfText, content, StringComparison.OrdinalIgnoreCase);
}
protected void AssertBuildProject(string projectPath, string projectName, string platform, bool deleteAfterBuild = true)
{
(int exitCode, string outputFile) result = (1, string.Empty);
// Build solution
switch (platform)
{
case Platforms.Uwp:
result = _fixture.BuildSolutionUwp(projectName, projectPath, platform);
break;
case Platforms.Wpf:
result = _fixture.BuildSolutionWpf(projectName, projectPath, platform);
break;
}
// Assert
Assert.True(result.exitCode.Equals(0), $"Solution {projectName} was not built successfully. {Environment.NewLine}Errors found: {_fixture.GetErrorLines(result.outputFile)}.{Environment.NewLine}Please see {Path.GetFullPath(result.outputFile)} for more details.");
// Clean
if (deleteAfterBuild)
{
Fs.SafeDeleteDirectory(projectPath);
}
}
protected void AssertBuildProjectWpfWithMsix(string projectPath, string projectName, string platform, bool deleteAfterBuild = true)
{
// Build solution
var (exitCode, outputFile) = _fixture.BuildSolutionWpfWithMsix(projectName, projectPath, platform);
// Assert
Assert.True(exitCode.Equals(0), $"Solution {projectName} was not built successfully. {Environment.NewLine}Errors found: {_fixture.GetErrorLines(outputFile)}.{Environment.NewLine}Please see {Path.GetFullPath(outputFile)} for more details.");
// Clean
if (deleteAfterBuild)
{
Fs.SafeDeleteDirectory(projectPath);
}
}
protected void AssertBuildProjectThenRunTests(string projectPath, string projectName, string platform)
{
var (buildExitCode, buildOutputFile) = _fixture.BuildSolutionUwp(projectName, projectPath, platform);
if (buildExitCode.Equals(0))
{
var (testExitCode, testOutputFile) = _fixture.RunTests(projectName, projectPath);
var summary = _fixture.GetTestSummary(testOutputFile);
Assert.True(
summary.Contains("Failed: 0.") || !summary.Contains("Failed"),
$"Tests failed. {Environment.NewLine}{summary}{Environment.NewLine}Please see {Path.GetFullPath(buildOutputFile)} for more details.");
}
else
{
Assert.True(buildExitCode.Equals(0), $"Solution {projectName} was not built successfully. {Environment.NewLine}Errors found: {_fixture.GetErrorLines(buildOutputFile)}.{Environment.NewLine}Please see {Path.GetFullPath(buildOutputFile)} for more details.");
}
// Tidy up if all tests passed
Fs.SafeDeleteDirectory(projectPath);
}
protected async Task<string> AssertGenerateRightClickAsync(string projectName, string projectType, string framework, string platform, string language, bool emptyProject, List<string> excludedGroupIdentity = null)
{
BaseGenAndBuildFixture.SetCurrentLanguage(language);
BaseGenAndBuildFixture.SetCurrentPlatform(platform);
var path = Path.Combine(_fixture.TestNewItemPath, projectName, projectName);
GenContext.Current = new FakeContextProvider
{
ProjectName = projectName,
DestinationPath = path,
GenerationOutputPath = path,
};
var userSelection = _fixture.SetupProject(projectType, framework, platform, language);
if (!emptyProject)
{
var templates = _fixture.Templates().Where(
t => t.GetTemplateType().IsItemTemplate()
&& (t.GetProjectTypeList().Contains(projectType) || t.GetProjectTypeList().Contains(All))
&& (t.GetFrontEndFrameworkList().Contains(framework) || t.GetFrontEndFrameworkList().Contains(All))
&& t.GetPlatform() == platform
&& (excludedGroupIdentity == null || (!excludedGroupIdentity.Contains(t.GroupIdentity)))
&& !t.GetIsHidden());
var templatesInfo = GenContext.ToolBox.Repo.GetTemplatesInfo(templates, platform, projectType, framework, _emptyBackendFramework);
_fixture.AddItems(userSelection, templatesInfo, BaseGenAndBuildFixture.GetDefaultName);
}
await NewProjectGenController.Instance.UnsafeGenerateProjectAsync(userSelection);
var project = Path.Combine(_fixture.TestNewItemPath, projectName);
// Assert on project
Assert.True(Directory.Exists(project));
int emptyProjecFileCount = Directory.GetFiles(project, "*.*", SearchOption.AllDirectories).Count();
Assert.True(emptyProjecFileCount > 2);
var rightClickTemplates = _fixture.Templates().Where(
t => t.GetTemplateType().IsItemTemplate()
&& (t.GetProjectTypeList().Contains(projectType) || t.GetProjectTypeList().Contains(All))
&& (t.GetFrontEndFrameworkList().Contains(framework) || t.GetFrontEndFrameworkList().Contains(All))
&& t.GetPlatform() == platform
&& !t.GetIsHidden()
&& (excludedGroupIdentity == null || (!excludedGroupIdentity.Contains(t.GroupIdentity)))
&& t.GetRightClickEnabled());
await AddRightClickTemplatesAsync(path, rightClickTemplates, projectName, projectType, framework, platform, language);
var finalProjectPath = Path.Combine(_fixture.TestNewItemPath, projectName);
int finalProjectFileCount = Directory.GetFiles(finalProjectPath, "*.*", SearchOption.AllDirectories).Count();
if (emptyProject)
{
Assert.True(finalProjectFileCount > emptyProjecFileCount);
}
else
{
Assert.True(finalProjectFileCount == emptyProjecFileCount);
}
return finalProjectPath;
}
protected async Task AddRightClickTemplatesAsync(string destinationPath, IEnumerable<ITemplateInfo> rightClickTemplates, string projectName, string projectType, string framework, string platform, string language)
{
// Add new items
foreach (var item in rightClickTemplates)
{
GenContext.Current = new FakeContextProvider
{
ProjectName = projectName,
DestinationPath = destinationPath,
GenerationOutputPath = GenContext.GetTempGenerationPath(projectName),
};
var newUserSelection = new UserSelection(projectType, framework, _emptyBackendFramework, platform, language)
{
HomeName = string.Empty,
ItemGenerationType = ItemGenerationType.GenerateAndMerge,
};
var templateInfo = GenContext.ToolBox.Repo.GetTemplateInfo(item, platform, projectType, framework, _emptyBackendFramework);
_fixture.AddItem(newUserSelection, templateInfo, BaseGenAndBuildFixture.GetDefaultName);
await NewItemGenController.Instance.UnsafeGenerateNewItemAsync(item.GetTemplateType(), newUserSelection);
NewItemGenController.Instance.UnsafeFinishGeneration(newUserSelection);
}
}
protected async Task<(string ProjectPath, string ProjecName)> AssertGenerationOneByOneAsync(string itemName, string projectType, string framework, string platform, string itemId, string language, bool cleanGeneration = true)
{
BaseGenAndBuildFixture.SetCurrentLanguage(language);
BaseGenAndBuildFixture.SetCurrentPlatform(platform);
var itemTemplate = _fixture.Templates().FirstOrDefault(t => t.Identity == itemId);
var finalName = itemTemplate.GetDefaultName();
if (itemTemplate.GetItemNameEditable())
{
var nameValidationService = new ItemNameService(GenContext.ToolBox.Repo.ItemNameValidationConfig, () => new string[] { });
finalName = nameValidationService.Infer(finalName);
}
var projectName = $"{ShortProjectType(projectType)}{finalName}{ShortLanguageName(language)}";
var destinationPath = Path.Combine(_fixture.TestProjectsPath, projectName, projectName);
GenContext.Current = new FakeContextProvider
{
ProjectName = projectName,
DestinationPath = destinationPath,
GenerationOutputPath = destinationPath,
};
var userSelection = _fixture.SetupProject(projectType, framework, platform, language);
var templateInfo = GenContext.ToolBox.Repo.GetTemplateInfo(itemTemplate, platform, projectType, framework, _emptyBackendFramework);
_fixture.AddItem(userSelection, templateInfo, BaseGenAndBuildFixture.GetDefaultName);
await NewProjectGenController.Instance.UnsafeGenerateProjectAsync(userSelection);
var resultPath = Path.Combine(_fixture.TestProjectsPath, projectName);
// Assert
Assert.True(Directory.Exists(resultPath));
Assert.True(Directory.GetFiles(resultPath, "*.*", SearchOption.AllDirectories).Count() > 2);
// Clean
if (cleanGeneration)
{
Fs.SafeDeleteDirectory(resultPath);
}
return (resultPath, projectName);
}
public static IEnumerable<object[]> GetProjectTemplatesForGeneration()
{
return GenerationFixture.GetProjectTemplates();
}
public static IEnumerable<object[]> GetCSharpUwpProjectTemplatesForGeneration()
{
var result = GenerationFixture.GetProjectTemplates();
foreach (var item in result)
{
if (item[2].ToString() == Platforms.Uwp && item[3].ToString() == ProgrammingLanguages.CSharp)
{
yield return item;
}
}
}
protected async Task<(string ProjectPath, string ProjectName)> SetUpComparisonProjectAsync(string language, string projectType, string framework, IEnumerable<string> genIdentities, bool lastPageIsHome = false, bool includeMultipleInstances = true)
{
BaseGenAndBuildFixture.SetCurrentLanguage(language);
BaseGenAndBuildFixture.SetCurrentPlatform(Platforms.Uwp);
var singlePageName = string.Empty;
var genIdentitiesList = genIdentities.ToList();
if (genIdentitiesList.Count == 1)
{
singlePageName = genIdentitiesList.Last().Split('.').Last();
}
var projectName = $"{projectType}{framework}{singlePageName}{ShortLanguageName(language)}";
var destinationPath = Path.Combine(_fixture.TestProjectsPath, projectName, projectName);
GenContext.Current = new FakeContextProvider
{
ProjectName = projectName,
DestinationPath = destinationPath,
GenerationOutputPath = destinationPath,
};
var userSelection = _fixture.SetupProject(projectType, framework, Platforms.Uwp, language);
foreach (var identity in genIdentitiesList)
{
var itemTemplate = _fixture.Templates().FirstOrDefault(t
=> (t.Identity.StartsWith($"{identity}.") || t.Identity.Equals(identity))
&& (t.GetProjectTypeList().Contains(projectType) || t.GetProjectTypeList().Contains(All))
&& (t.GetFrontEndFrameworkList().Contains(framework) || t.GetFrontEndFrameworkList().Contains(All)));
var templateInfo = GenContext.ToolBox.Repo.GetTemplateInfo(itemTemplate, Platforms.Uwp, projectType, framework, _emptyBackendFramework);
_fixture.AddItem(userSelection, templateInfo, BaseGenAndBuildFixture.GetDefaultName);
// Add multiple pages if supported to check these are handled the same
if (includeMultipleInstances && templateInfo.MultipleInstance)
{
_fixture.AddItem(userSelection, templateInfo, BaseGenAndBuildFixture.GetDefaultName);
}
}
if (lastPageIsHome)
{
// Useful if creating a blank project type and want to change the start page
userSelection.HomeName = userSelection.Pages.Last().Name;
if (projectType == "TabbedNav")
{
userSelection.Pages.Reverse();
}
}
await NewProjectGenController.Instance.UnsafeGenerateProjectAsync(userSelection);
var resultPath = Path.Combine(_fixture.TestProjectsPath, GenContext.Current.ProjectName);
return (resultPath, GenContext.Current.ProjectName);
}
public static IEnumerable<object[]> GetPageAndFeatureTemplatesForGeneration(string framework)
{
var result = GenerationFixture.GetPageAndFeatureTemplatesForGeneration(framework);
return result;
}
private const string NavigationPanel = "SplitView";
private const string Blank = "Blank";
private const string TabbedNav = "TabbedNav";
private const string MenuBar = "MenuBar";
private const string MvvmBasic = "MVVMBasic";
private const string MvvmLight = "MVVMLight";
private const string CodeBehind = "CodeBehind";
// This returns a list of project types and frameworks supported by BOTH C# and VB
public static IEnumerable<object[]> GetMultiLanguageProjectsAndFrameworks()
{
yield return new object[] { NavigationPanel, CodeBehind };
yield return new object[] { NavigationPanel, MvvmBasic };
yield return new object[] { NavigationPanel, MvvmLight };
yield return new object[] { Blank, CodeBehind };
yield return new object[] { Blank, MvvmBasic };
yield return new object[] { Blank, MvvmLight };
yield return new object[] { TabbedNav, CodeBehind };
yield return new object[] { TabbedNav, MvvmBasic };
yield return new object[] { TabbedNav, MvvmLight };
yield return new object[] { MenuBar, CodeBehind };
yield return new object[] { MenuBar, MvvmBasic };
yield return new object[] { MenuBar, MvvmLight };
}
// Gets a list of partial identities for page and feature templates supported by C# and VB
protected static IEnumerable<string> GetTemplatesThatDoNotSupportVB()
{
return new[]
{
"wts.Service.WebApi",
"wts.Service.SecuredWebApi",
"wts.Service.SecuredWebApi.CodeBehind"
};
}
// Set a single programming language to stop the fixture using all languages available to it
public static IEnumerable<object[]> GetProjectTemplatesForBuild(string framework, string programmingLanguage, string platform)
{
IEnumerable<object[]> result = new List<object[]>();
switch (framework)
{
case "CodeBehind":
result = BuildTemplatesTestFixture.GetProjectTemplates(framework, programmingLanguage, platform);
break;
case "MVVMBasic":
result = BuildTemplatesTestFixture.GetProjectTemplates(framework, programmingLanguage, platform);
break;
case "MVVMLight":
result = BuildTemplatesTestFixture.GetProjectTemplates(framework, programmingLanguage, platform);
break;
case "CaliburnMicro":
result = BuildTemplatesTestFixture.GetProjectTemplates(framework, programmingLanguage, platform);
break;
case "LegacyFrameworks":
if (programmingLanguage == ProgrammingLanguages.CSharp)
{
result = BuildRightClickWithLegacyCSharpFixture.GetProjectTemplates();
}
if (programmingLanguage == ProgrammingLanguages.VisualBasic)
{
result = BuildRightClickWithLegacyVBFixture.GetProjectTemplates();
}
break;
case "Prism":
result = BuildTemplatesTestFixture.GetProjectTemplates(framework, programmingLanguage, platform);
break;
default:
throw new ArgumentOutOfRangeException(nameof(framework));
}
return result;
}
public static IEnumerable<object[]> GetPageAndFeatureTemplatesForBuild(string framework, string language = ProgrammingLanguages.CSharp, string platform = Platforms.Uwp, string excludedItem = "")
{
IEnumerable<object[]> result = new List<object[]>();
switch (framework)
{
case "CodeBehind":
result = BuildTemplatesTestFixture.GetPageAndFeatureTemplatesForBuild(framework, language, platform, excludedItem);
break;
case "MVVMBasic":
result = BuildTemplatesTestFixture.GetPageAndFeatureTemplatesForBuild(framework, language, platform, excludedItem);
break;
case "MVVMLight":
result = BuildTemplatesTestFixture.GetPageAndFeatureTemplatesForBuild(framework, language, platform, excludedItem);
break;
case "CaliburnMicro":
result = BuildTemplatesTestFixture.GetPageAndFeatureTemplatesForBuild(framework, language, platform, excludedItem);
break;
case "Prism":
result = BuildTemplatesTestFixture.GetPageAndFeatureTemplatesForBuild(framework, language, platform, excludedItem);
break;
}
return result;
}
}
}