forked from microsoft/TemplateStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemplatePathTests.cs
More file actions
60 lines (49 loc) · 1.85 KB
/
TemplatePathTests.cs
File metadata and controls
60 lines (49 loc) · 1.85 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
// 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 Xunit;
namespace Microsoft.Templates.Test
{
[Trait("ExecutionSet", "Minimum")]
[Trait("ExecutionSet", "TemplateValidation")]
[Trait("ExecutionSet", "_CIBuild")]
[Trait("ExecutionSet", "_Full")]
public class TemplatePathTests
{
[Fact]
public void EnsureTemplateFilesDoNotExceedPathLength()
{
// This is the relative path from where the test assembly will run from
const string templatesRoot = "../../../../../Templates";
var exceedingTemplates = new List<string>();
foreach (var file in GetFiles(templatesRoot))
{
var path = Path.GetFullPath(file);
var templateRoot = Path.GetFullPath(templatesRoot);
var relativePath = path.Replace(templateRoot, string.Empty);
if (relativePath.Length > 130)
{
exceedingTemplates.Add(relativePath);
}
}
Assert.True(exceedingTemplates.Count == 0, $"Following templates exceed 130 chars: {string.Join(Environment.NewLine, exceedingTemplates.ToArray())}");
}
private IEnumerable<string> GetFiles(string directory)
{
foreach (var dir in Directory.GetDirectories(directory))
{
foreach (var file in Directory.GetFiles(dir))
{
yield return file;
}
foreach (var file in GetFiles(dir))
{
yield return file;
}
}
}
}
}