forked from microsoft/TemplateStudio
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLanguageSyncTests.cs
More file actions
69 lines (60 loc) · 2.67 KB
/
Copy pathLanguageSyncTests.cs
File metadata and controls
69 lines (60 loc) · 2.67 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
// 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("Type", "TemplateValidation")]
[Trait("ExecutionSet", "Minimum")]
[Trait("ExecutionSet", "TemplateValidation")]
[Trait("ExecutionSet", "_CIBuild")]
[Trait("ExecutionSet", "_Full")]
public class LanguageSyncTests
{
[Fact]
public void EnsureVbTemplatesUseTranslatedDescriptionsIfCsOnesDo()
{
// This is the relative path from where the test assembly will run from
const string templatesRoot = "../../../../../Templates";
// Just check Czech files because text will be translated to all languages or none.
// Just check the description but the fix will also copy 'xx-XX.template.json'
foreach (var file in GetFiles(templatesRoot, "cs-CZ.description.md"))
{
// Only interested in templates with a VB version
if (file.Contains("._VB\\"))
{
var czechFileContents = File.ReadAllText(file);
var defaultFileContents = File.ReadAllText(file.Replace("cs-CZ.", string.Empty));
if (czechFileContents == defaultFileContents)
{
var csVersionOfCzechFileContents = File.ReadAllText(file.Replace("._VB\\", "\\"));
if (csVersionOfCzechFileContents != czechFileContents)
{
// Can end on first failure as PS script will fix missing translations for all templates
Assert.True(false, $"'{file}' is not translated but it's C# equivalent is.{Environment.NewLine}Run the script at '_utils\\Synchronize-Files-Used-By-VisualBasic-Templates.ps1' to copy the translations.");
}
}
}
}
// If we get here everything is ok.
Assert.True(true);
}
private IEnumerable<string> GetFiles(string directory, string searchPattern)
{
foreach (var dir in Directory.GetDirectories(directory))
{
foreach (var file in Directory.GetFiles(dir, searchPattern))
{
yield return file;
}
foreach (var file in GetFiles(dir, searchPattern))
{
yield return file;
}
}
}
}
}