Skip to content

Commit bb323b0

Browse files
Merge branch 'v8/dev' into v8/contrib
2 parents f68dba7 + 1553f02 commit bb323b0

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Xml;
6+
using NUnit.Framework;
7+
using Umbraco.Tests.TestHelpers;
8+
9+
namespace Umbraco.Tests.Configurations
10+
{
11+
[TestFixture]
12+
public class LanguageXmlTests
13+
{
14+
[Test]
15+
public void Can_Load_Language_Xml_Files()
16+
{
17+
var languageDirectory = GetLanguageDirectory();
18+
var readFilesCount = 0;
19+
var xmlDocument = new XmlDocument();
20+
foreach (var languageFile in languageDirectory.EnumerateFiles("*.xml"))
21+
{
22+
// Load will throw an exception if the XML isn't valid.
23+
xmlDocument.Load(languageFile.FullName);
24+
readFilesCount++;
25+
}
26+
27+
// Ensure that at least one file was read.
28+
Assert.AreNotEqual(0, readFilesCount);
29+
}
30+
31+
private static DirectoryInfo GetLanguageDirectory()
32+
{
33+
var testDirectoryPathParts = Path.GetDirectoryName(TestContext.CurrentContext.TestDirectory)
34+
.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
35+
var solutionDirectoryPathParts = testDirectoryPathParts
36+
.Take(Array.IndexOf(testDirectoryPathParts, "src") + 1);
37+
var languageFolderPathParts = new List<string>(solutionDirectoryPathParts);
38+
var additionalPathParts = new[] { "Umbraco.Web.UI", "Umbraco", "config", "lang" };
39+
languageFolderPathParts.AddRange(additionalPathParts);
40+
41+
// Hack for build-server - when this path is generated in that envrionment it's missing the "src" folder.
42+
// Not sure why, but if it's missing we'll add it in the right place.
43+
if (!languageFolderPathParts.Contains("src"))
44+
{
45+
languageFolderPathParts.Insert(languageFolderPathParts.Count - additionalPathParts.Length, "src");
46+
}
47+
48+
return new DirectoryInfo(string.Join(Path.DirectorySeparatorChar.ToString(), languageFolderPathParts));
49+
}
50+
}
51+
}

src/Umbraco.Tests/Umbraco.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
<Compile Include="Composing\CompositionTests.cs" />
121121
<Compile Include="Composing\LightInjectValidation.cs" />
122122
<Compile Include="Composing\ContainerConformingTests.cs" />
123+
<Compile Include="Configurations\LanguageXmlTests.cs" />
123124
<Compile Include="Configurations\GlobalSettingsTests.cs" />
124125
<Compile Include="CoreThings\CallContextTests.cs" />
125126
<Compile Include="Components\ComponentTests.cs" />

0 commit comments

Comments
 (0)