Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public FileParatextProjectSettingsParser(string projectDir)

protected override UsfmStylesheet CreateStylesheet(string fileName)
{
string customStylesheetFileName = Path.Combine(_projectDir, fileName);
string customStylesheetFileName = Path.Combine(_projectDir, "custom.sty");
return new UsfmStylesheet(
fileName,
File.Exists(customStylesheetFileName) ? customStylesheetFileName : null
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using NUnit.Framework;

namespace SIL.Machine.Corpora;

public class FileParatextProjectSettingsParserTests
{
[Test]
public void Parse_CustomStylesheet()
{
FileParatextProjectSettingsParser parser = new(CorporaTestHelpers.UsfmTestProjectPath);
ParatextProjectSettings settings = parser.Parse();
UsfmTag testTag = settings.Stylesheet.GetTag("test");
Assert.That(testTag.StyleType, Is.EqualTo(UsfmStyleType.Character));
Assert.That(testTag.TextType, Is.EqualTo(UsfmTextType.Other));
}
}
4 changes: 4 additions & 0 deletions tests/SIL.Machine.Tests/Corpora/TestData/usfm/Tes/custom.sty
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\Marker test
\Endmarker test*
\TextType Other
\StyleType Character
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.IO.Compression;
using NUnit.Framework;
using SIL.ObjectModel;

namespace SIL.Machine.Corpora;

public class ZipParatextProjectSettingsParserTests
{
[Test]
public void Parse_CustomStylesheet()
{
using var env = new TestEnvironment();
ParatextProjectSettings settings = env.Parser.Parse();
UsfmTag testTag = settings.Stylesheet.GetTag("test");
Assert.That(testTag.StyleType, Is.EqualTo(UsfmStyleType.Character));
Assert.That(testTag.TextType, Is.EqualTo(UsfmTextType.Other));
}

private class TestEnvironment : DisposableBase
{
private readonly string _backupPath;
private readonly ZipArchive _archive;

public TestEnvironment()
{
_backupPath = CorporaTestHelpers.CreateTestParatextBackup();
_archive = ZipFile.OpenRead(_backupPath);
Parser = new ZipParatextProjectSettingsParser(_archive);
}

public ZipParatextProjectSettingsParser Parser { get; }

protected override void DisposeManagedResources()
{
_archive.Dispose();
if (File.Exists(_backupPath))
File.Delete(_backupPath);
}
}
}
Loading