Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reintroduce language files tests (#12367)
* Reintroducing language files tests * Fix casing * Update tests/Umbraco.Tests.UnitTests/Umbraco.Core/EmbeddedResources/LanguageXmlTests.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
- Loading branch information
1 parent
af4e3ca
commit 2ed71a6
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
tests/Umbraco.Tests.UnitTests/Umbraco.Core/EmbeddedResources/LanguageXmlTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.IO; | ||
using System.Linq; | ||
using System.Xml; | ||
using Microsoft.Extensions.FileProviders; | ||
using NUnit.Framework; | ||
using Umbraco.Cms.Core.Composing; | ||
|
||
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.EmbeddedResources | ||
{ | ||
[TestFixture] | ||
public class LanguageXmlTests | ||
{ | ||
[Test] | ||
public void Can_Load_Language_Xml_Files() | ||
{ | ||
var readFilesCount = 0; | ||
var xmlDocument = new XmlDocument(); | ||
|
||
var languageProvider = new EmbeddedFileProvider(typeof(IAssemblyProvider).Assembly, "Umbraco.Cms.Core.EmbeddedResources.Lang"); | ||
var files = languageProvider.GetDirectoryContents(string.Empty) | ||
.Where(x => !x.IsDirectory && x.Name.EndsWith(".xml")); | ||
|
||
foreach (var languageFile in files) | ||
{ | ||
using var stream = new StreamReader(languageFile.CreateReadStream()); | ||
|
||
// Load will throw an exception if the XML isn't valid. | ||
xmlDocument.Load(stream); | ||
readFilesCount++; | ||
} | ||
|
||
// Ensure that at least one file was read. | ||
Assert.AreNotEqual(0, readFilesCount); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters