Skip to content

Commit

Permalink
Only run this test on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
bergmania committed Nov 3, 2021
1 parent ab96e7c commit fb953ad
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Configurations
public class LanguageXmlTests
{
[Test]
[Platform("Win")] //TODO figure out why Path.GetFullPath("/mnt/c/...") is not considered an absolute path on linux + mac
public void Can_Load_Language_Xml_Files()
{
var languageDirectory = GetLanguageDirectory();
var languageDirectoryPath = GetLanguageDirectory();
var readFilesCount = 0;
var xmlDocument = new XmlDocument();
foreach (var languageFile in languageDirectory.EnumerateFiles("*.xml"))

var directoryInfo = new DirectoryInfo(languageDirectoryPath);
Console.WriteLine("directoryInfo:" + directoryInfo);
Console.WriteLine("FullName:" + directoryInfo.FullName);

foreach (var languageFile in directoryInfo.GetFiles("*.xml", SearchOption.TopDirectoryOnly))
{
// Load will throw an exception if the XML isn't valid.
xmlDocument.Load(languageFile.FullName);
Expand All @@ -27,10 +33,11 @@ public void Can_Load_Language_Xml_Files()
Assert.AreNotEqual(0, readFilesCount);
}

private static DirectoryInfo GetLanguageDirectory()
private static string GetLanguageDirectory()
{
var testDirectoryPathParts = Path.GetDirectoryName(TestContext.CurrentContext.TestDirectory)
.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);

var solutionDirectoryPathParts = testDirectoryPathParts
.Take(Array.IndexOf(testDirectoryPathParts, "tests"));
var languageFolderPathParts = new List<string>(solutionDirectoryPathParts);
Expand All @@ -44,7 +51,7 @@ private static DirectoryInfo GetLanguageDirectory()
languageFolderPathParts.Insert(languageFolderPathParts.Count - additionalPathParts.Length, "src");
}

return new DirectoryInfo(string.Join(Path.DirectorySeparatorChar.ToString(), languageFolderPathParts));
return string.Join(Path.DirectorySeparatorChar.ToString(), languageFolderPathParts);
}
}
}

0 comments on commit fb953ad

Please sign in to comment.