/// ------------------------------------------------------------------------------------ /// <summary> /// Open the file. This is virtual so it can be replaced in testing with an /// in-memory file writer. /// </summary> /// <param name="fileName"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ protected override FileWriter OpenFile(string fileName) { DummyFileWriter writer = new DummyFileWriter(); writer.Open(fileName); return(writer); }
/// ------------------------------------------------------------------------------------ /// <summary> /// constructor /// </summary> /// ------------------------------------------------------------------------------------ public DummyExportUsfm(FdoCache cache, FilteredScrBooks filter) : base(cache, filter, string.Empty) { if (m_file != null) m_file.Close(); m_file = new DummyFileWriter(); // Usually this is set by the main window and most tests need this. m_requestedAnalWS = new int[] { m_defaultAnalWS }; }
/// ------------------------------------------------------------------------------------ /// <summary> /// constructor /// </summary> /// ------------------------------------------------------------------------------------ public DummyExportUsfm(FdoCache cache, FilteredScrBooks filter) : base(cache, filter, string.Empty) { if (m_file != null) { m_file.Close(); } m_file = new DummyFileWriter(); // Usually this is set by the main window and most tests need this. m_requestedAnalWS = new int[] { m_defaultAnalWS }; }
public void UpdateParatextLdsFile_GeneralSectionMissing() { if (File.Exists("test.lds")) { File.Delete("test.lds"); } int wsHvo = Cache.DefaultVernWs; LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo); vernWs.Name.UserDefaultWritingSystem = "French"; DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry(); StyleInfoTable styleTable = new StyleInfoTable("Normal", Cache.LanguageWritingSystemFactoryAccessor); styleTable.Add("Normal", normalEntry); normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000; normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings"; string ldsContentsOrig = "[OtherStuff]"; DummyFileWriter writer = new DummyFileWriter(); writer.Open("test.lds"); ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache); ReflectionHelper.CallMethod(ldsAccessor, "UpdateLdsContents", ldsContentsOrig, normalEntry, Cache.DefaultVernWs, writer); // Verify the .lds file string[] expectedLdsContents = { "[OtherStuff]", //Environment.NewLine + "[General]", "codepage=65001", "font=Wingdings", "size=14", "name=French", "RTL=F" }; writer.VerifyOutput(expectedLdsContents); }
public void WriteParatextLdsFile() { if (File.Exists("test.lds")) { File.Delete("test.lds"); } int wsHvo = Cache.DefaultVernWs; LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo); vernWs.Name.UserDefaultWritingSystem = "French"; DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry(); StyleInfoTable styleTable = new StyleInfoTable("Normal", Cache.LanguageWritingSystemFactoryAccessor); styleTable.Add("Normal", normalEntry); normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000; normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings"; ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache); DummyFileWriter actualLds = new DummyFileWriter(); ReflectionHelper.CallMethod(ldsAccessor, "WriteParatextLdsFile", "test.lds", Cache.DefaultVernWs, normalEntry, actualLds); // Verify the .lds file string[] expectedLds = { "[General]", "codepage=65001", "RTL=F", "font=Wingdings", "name=French", "size=14", string.Empty, "[Checking]", string.Empty, "[Characters]", string.Empty, "[Punctuation]" }; actualLds.VerifyOutput(expectedLds); }
public void WriteParatextLdsFile_BT() { if (File.Exists("test.lds")) { File.Delete("test.lds"); } int wsUrduBT = InMemoryFdoCache.s_wsHvos.Ur; IWritingSystem btWs = Cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(wsUrduBT); string btWsName = btWs.get_UiName(Cache.DefaultUserWs); DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry(); StyleInfoTable styleTable = new StyleInfoTable("Normal", Cache.LanguageWritingSystemFactoryAccessor); styleTable.Add("Normal", normalEntry); normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000; normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings"; DummyFileWriter fileWriterLDS = new DummyFileWriter(); ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache); ReflectionHelper.CallMethod(ldsAccessor, "WriteParatextLdsFile", "test.lds", wsUrduBT, normalEntry, fileWriterLDS); // Verify the .lds file string[] expectedLds = { "[General]", "codepage=65001", "RTL=T", "font=Wingdings", "name=" + btWs.get_UiName(Cache.DefaultUserWs), "size=14", string.Empty, "[Checking]", string.Empty, "[Characters]", string.Empty, "[Punctuation]" }; fileWriterLDS.VerifyOutput(expectedLds); }
public void WriteParatextSsfFile_SeptuagintVersification() { int wsHvo = Cache.DefaultVernWs; m_scr.Versification = Paratext.ScrVers.Septuagint; LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo); vernWs.Name.UserDefaultWritingSystem = "French"; DummyFileWriter writer = new DummyFileWriter(); FileNameFormat fileNameFormat = new FileNameFormat("pre", FileNameFormat.SchemeFormat.NNBBB, "suf", "ext"); m_exporter.ParatextSsfFileAccessor.SaveSsfFile(fileNameFormat, "dummy", "styFile.sty", @"C:\My Paratext Projects\dummy", writer, Cache.DefaultVernWs); // Verify the .ssf file string[] expectedSsf = new string[] { @"<ScriptureText>", @"<BooksPresent>100000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000</BooksPresent>", @"<Copyright></Copyright>", @"<Directory>C:\My Paratext Projects\dummy</Directory>", @"<Editable>T</Editable>", @"<Encoding>65001</Encoding>", @"<FileNameForm>41MAT</FileNameForm>", @"<FileNamePostPart>suf.ext</FileNamePostPart>", @"<FileNamePrePart>pre</FileNamePrePart>", @"<FullName>" + Cache.LangProject.Name.UserDefaultWritingSystem + "</FullName>", @"<Language>French</Language>", @"<LeftToRight>" + (vernWs.RightToLeft ? "F" : "T") + "</LeftToRight>", @"<Name>dummy</Name>", @"<StyleSheet>styFile.sty</StyleSheet>", @"<Versification>2</Versification>", // Septuagint "<Naming PrePart=\"pre\" PostPart=\"suf.ext\" BookNameForm=\"41MAT\"></Naming>", @"</ScriptureText>" }; writer.VerifyOutput(expectedSsf); }
public void WriteUsfmStyFile() { CheckDisposed(); DummyUsfmStyEntry entry = new DummyUsfmStyEntry(); m_exporter.UsfmStyFileAccessor.Add("id", entry); entry.P6Name = "(id) File - Identification"; entry.Description = "File identification information (BOOKID, FILENAME, EDITOR, MODIFICATION DATE)"; entry.IsParagraphStyle = true; entry.Context = ContextValues.Book; entry.Structure = StructureValues.Undefined; entry.TextPropertiesFromStyFile = "paragraph nonpublishable nonvernacular book"; entry.DefaultFontInfo.m_fontSize.ExplicitValue = 12000; entry = new DummyUsfmStyEntry(); m_exporter.UsfmStyFileAccessor.Add("c", entry); entry.Name = "Chapter Number"; entry.P6Name = "(c) Chapter Number"; entry.Description = "Chapter number (necessary for normal Paratext operation)"; entry.IsParagraphStyle = false; entry.OccursUnder = "id"; entry.Rank = 8; entry.Context = ContextValues.Text; entry.Structure = StructureValues.Body; entry.Function = FunctionValues.Chapter; entry.DefaultFontInfo.m_bold.ExplicitValue = true; entry.DefaultFontInfo.m_fontSize.ExplicitValue = 18000; entry.SpaceBefore = 8000; entry.SpaceAfter = 4000; entry = new DummyUsfmStyEntry(); m_exporter.UsfmStyFileAccessor.Add("v", entry); entry.Name = "Verse Number"; entry.P6Name = "(v) Verse Number"; entry.Description = "A verse number (Necessary for normal paratext operation)"; entry.IsParagraphStyle = false; entry.OccursUnder = "li li1 li2 li3 li4 m mi mis nb p pc ph phi pi pr ps psi q q1 q2 q3 qc qr tc1 tc2 tc3 tc4 s3 d"; entry.Context = ContextValues.Text; entry.Structure = StructureValues.Body; entry.Function = FunctionValues.Verse; entry.DefaultFontInfo.m_fontSize.ExplicitValue = 12000; entry.DefaultFontInfo.m_superSub.ExplicitValue = FwSuperscriptVal.kssvSuper; entry = new DummyUsfmStyEntry(); m_exporter.UsfmStyFileAccessor.Add("p", entry); entry.Name = "Paragraph"; entry.P6Name = "(p) Paragraph - Normal, First Line Indent"; entry.Description = "Paragraph text, with first line indent"; entry.IsParagraphStyle = true; entry.OccursUnder = "c"; entry.Rank = 4; entry.Context = ContextValues.Text; entry.Structure = StructureValues.Body; entry.Function = FunctionValues.Prose; entry.DefaultFontInfo.m_fontSize.ExplicitValue = 12000; entry.FirstLineIndent = (int)(0.125 * 72000); entry = new DummyUsfmStyEntry(); m_exporter.UsfmStyFileAccessor.Add("rem", entry); entry.Name = "Remark"; entry.P6Name = "(rem) File - Remark"; entry.Description = "Comments and remarks"; entry.OccursUnder = "id ide"; entry.IsParagraphStyle = true; entry.Context = ContextValues.Annotation; entry.Structure = StructureValues.Undefined; entry.DefaultFontInfo.m_fontSize.ExplicitValue = 12000; entry.DefaultFontInfo.m_fontColor.ExplicitValue = ColorUtil.ConvertBGRtoColor((uint)16711680); entry = new DummyUsfmStyEntry(); m_exporter.UsfmStyFileAccessor.Add("Custom_User-defined_Style", entry); entry.Name = "Custom User-defined Style"; entry.IsParagraphStyle = true; entry.Context = ContextValues.Text; entry.Structure = StructureValues.Body; entry.Function = FunctionValues.Prose; entry.DefaultFontInfo.m_fontSize.ExplicitValue = 10000; entry.DefaultFontInfo.m_fontName.ExplicitValue = "Courier New"; entry.SpaceAfter = 6000; entry = new DummyUsfmStyEntry(); m_exporter.UsfmStyFileAccessor.Add("is2", entry); entry.Name = "Intro Section Head Minor"; entry.P6Name = "(is2) Introduction - Section Heading Level 2"; entry.Description = "Introduction section heading, level 2 "; entry.IsParagraphStyle = true; entry.Context = ContextValues.Intro; entry.Structure = StructureValues.Heading; entry.Function = FunctionValues.Prose; entry.OccursUnder = "id"; entry.Rank = 6; entry.Level = 2; entry.NotRepeatable = true; entry.DefaultFontInfo.m_fontSize.ExplicitValue = 12000; entry.DefaultFontInfo.m_bold.ExplicitValue = true; entry.Alignment = FwTextAlign.ktalCenter; entry.SpaceBefore = 8000; entry.SpaceAfter = 4000; entry = new DummyUsfmStyEntry(); m_exporter.UsfmStyFileAccessor.Add("f", entry); entry.P6Name = "(f...f*) Footnote "; entry.Endmarker = "f*"; entry.IsParagraphStyle = true; entry.Context = ContextValues.Note; entry.OccursUnder = "c li li1 li2 li3 li4 m mi mis nb p pc ph phi pi pr ps psi q q1 q2 q3 qc qr sp tc1 tc2 tc3 tc4 ms ms1 ms2 s s1 s2 s3 spd d ip"; entry.TextPropertiesFromStyFile = "publishable vernacular note"; entry.DefaultFontInfo.m_fontSize.ExplicitValue = 12000; entry.XmlTag = "<usfm:f>"; entry = new DummyUsfmStyEntry(); m_exporter.UsfmStyFileAccessor.Add("b", entry); entry.P6Name = "(b) Poetry - Stanza Break (Blank Line)"; entry.IsParagraphStyle = true; entry.Context = ContextValues.Text; entry.Structure = StructureValues.Body; entry.Function = FunctionValues.Prose; entry.TextPropertiesFromStyFile = "paragraph publishable vernacular poetic"; entry.Poetic = true; entry.DefaultFontInfo.m_fontSize.ExplicitValue = 5000; entry.DefaultFontInfo.m_italic.ExplicitValue = true; entry.DefaultFontInfo.m_underline.ExplicitValue = FwUnderlineType.kuntSingle; entry.LeadingIndent = (int)(.25 * 72000); entry.TrailingIndent = (int)(.25 * 72000); DummyFileWriter writer = new DummyFileWriter(); m_exporter.UsfmStyFileAccessor.SaveStyFile("Test project", writer, -1); // Verify the .sty file string[] expectedSty = new string[] { "## Stylesheet for exported TE project Test project ##", "", @"\Marker b", @"\Name (b) Poetry - Stanza Break (Blank Line)", @"\TextType VerseText", @"\TextProperties paragraph publishable vernacular poetic", @"\StyleType Paragraph", @"\Italic", @"\Underline", @"\FontSize 5", @"\LeftMargin .250", @"\RightMargin .250", "", @"\Marker c", @"\TEStyleName Chapter Number", @"\Name (c) Chapter Number", @"\Description Chapter number (necessary for normal Paratext operation)", @"\OccursUnder id", @"\Rank 8", @"\TextType ChapterNumber", @"\TextProperties chapter", @"\StyleType Paragraph", @"\Bold", @"\FontSize 18", @"\SpaceBefore 8", @"\SpaceAfter 4", "", @"\Marker Custom_User-defined_Style", @"\TEStyleName Custom User-defined Style", @"\Name Custom User-defined Style", @"\TextType VerseText", @"\TextProperties paragraph publishable vernacular", @"\StyleType Paragraph", @"\FontName Courier New", @"\FontSize 10", @"\SpaceAfter 6", "", @"\Marker f", @"\Endmarker f*", @"\Name (f...f*) Footnote", @"\OccursUnder c li li1 li2 li3 li4 m mi mis nb p pc ph phi pi pr ps psi q q1 q2 q3 qc qr sp tc1 tc2 tc3 tc4 ms ms1 ms2 s s1 s2 s3 spd d ip", @"\TextType NoteText", @"\TextProperties publishable vernacular note", @"\StyleType Note", @"\FontSize 12", @"\XMLTag <usfm:f>", "", @"\Marker id", @"\Name (id) File - Identification", @"\Description File identification information (BOOKID, FILENAME, EDITOR, MODIFICATION DATE)", @"\TextType Other", @"\TextProperties paragraph nonpublishable nonvernacular book", @"\StyleType Paragraph", @"\FontSize 12", "", @"\Marker is2", @"\TEStyleName Intro Section Head Minor", @"\Name (is2) Introduction - Section Heading Level 2", @"\Description Introduction section heading, level 2", @"\OccursUnder id", @"\Rank 6", @"\NotRepeatable", @"\TextType Section", @"\TextProperties paragraph publishable vernacular level_2", @"\StyleType Paragraph", @"\Bold", @"\FontSize 12", @"\Justification Center", @"\SpaceBefore 8", @"\SpaceAfter 4", "", @"\Marker p", @"\TEStyleName Paragraph", @"\Name (p) Paragraph - Normal, First Line Indent", @"\Description Paragraph text, with first line indent", @"\OccursUnder c", @"\Rank 4", @"\TextType VerseText", @"\TextProperties paragraph publishable vernacular", @"\StyleType Paragraph", @"\FontSize 12", @"\FirstLineIndent .125", "", @"\Marker rem", @"\TEStyleName Remark", @"\Name (rem) File - Remark", @"\Description Comments and remarks", @"\OccursUnder id ide", @"\TextType Other", @"\TextProperties paragraph nonpublishable nonvernacular", @"\StyleType Paragraph", @"\FontSize 12", @"\Color 16711680", "", @"\Marker v", @"\TEStyleName Verse Number", @"\Name (v) Verse Number", @"\Description A verse number (Necessary for normal paratext operation)", @"\OccursUnder li li1 li2 li3 li4 m mi mis nb p pc ph phi pi pr ps psi q q1 q2 q3 qc qr tc1 tc2 tc3 tc4 s3 d", @"\TextType VerseNumber", @"\TextProperties verse", @"\StyleType Character", @"\Superscript", @"\FontSize 12", "" }; writer.VerifyOutput(expectedSty); }
public void UpdateParatextLdsFile_UpdateFontAndSizeAndAddRTL() { if (File.Exists("test.lds")) { File.Delete("test.lds"); } int wsHvo = Cache.DefaultVernWs; LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo); vernWs.Name.UserDefaultWritingSystem = "French"; DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry(); StyleInfoTable styleTable = new StyleInfoTable("Normal", Cache.LanguageWritingSystemFactoryAccessor); styleTable.Add("Normal", normalEntry); normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000; normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings"; string ldsContentsOrig = "[General]" + Environment.NewLine + "codepage=65001" + Environment.NewLine + "DialogFontsize=0" + Environment.NewLine + "LowerCaseLetters=" + Environment.NewLine + "NoCaseLetters=" + Environment.NewLine + "UpperCaseLetters=" + Environment.NewLine + "errors=" + Environment.NewLine + "font=Arial" + Environment.NewLine + "name=French" + Environment.NewLine + "separator=" + Environment.NewLine + "size=32" + Environment.NewLine + Environment.NewLine + "[Checking]" + Environment.NewLine + Environment.NewLine + "[Characters]" + Environment.NewLine + Environment.NewLine + "[Punctuation]" + Environment.NewLine + "diacritics=" + Environment.NewLine + "medial="; DummyFileWriter writer = new DummyFileWriter(); writer.Open("test.lds"); ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache); ReflectionHelper.CallMethod(ldsAccessor, "UpdateLdsContents", ldsContentsOrig, normalEntry, Cache.DefaultVernWs, writer); // Verify the .lds file string[] expectedLdsContents = { "[General]", "codepage=65001", "DialogFontsize=0", "LowerCaseLetters=", "NoCaseLetters=", "UpperCaseLetters=", "errors=", "font=Wingdings", "name=French", "separator=", "size=14", "RTL=F", //Environment.NewLine, string.Empty "[Checking]", //Environment.NewLine, string.Empty "[Characters]", //Environment.NewLine, string.Empty "[Punctuation]", "diacritics=", "medial=" }; ((DummyFileWriter)writer).VerifyOutput(expectedLdsContents); }
public void WriteParatextLdsFile() { if (File.Exists("test.lds")) File.Delete("test.lds"); int wsHvo = Cache.DefaultVernWs; LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo); vernWs.Name.UserDefaultWritingSystem = "French"; DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry(); StyleInfoTable styleTable = new StyleInfoTable("Normal", Cache.LanguageWritingSystemFactoryAccessor); styleTable.Add("Normal", normalEntry); normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000; normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings"; ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache); DummyFileWriter actualLds = new DummyFileWriter(); ReflectionHelper.CallMethod(ldsAccessor, "WriteParatextLdsFile", "test.lds", Cache.DefaultVernWs, normalEntry, actualLds); // Verify the .lds file string[] expectedLds = { "[General]", "codepage=65001", "RTL=F", "font=Wingdings", "name=French", "size=14", string.Empty, "[Checking]", string.Empty, "[Characters]", string.Empty, "[Punctuation]" }; actualLds.VerifyOutput(expectedLds); }
public void UpdateParatextLdsFile_GeneralSectionMissing() { if (File.Exists("test.lds")) File.Delete("test.lds"); int wsHvo = Cache.DefaultVernWs; LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo); vernWs.Name.UserDefaultWritingSystem = "French"; DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry(); StyleInfoTable styleTable = new StyleInfoTable("Normal", Cache.LanguageWritingSystemFactoryAccessor); styleTable.Add("Normal", normalEntry); normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000; normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings"; string ldsContentsOrig = "[OtherStuff]"; DummyFileWriter writer = new DummyFileWriter(); writer.Open("test.lds"); ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache); ReflectionHelper.CallMethod(ldsAccessor, "UpdateLdsContents", ldsContentsOrig, normalEntry, Cache.DefaultVernWs, writer); // Verify the .lds file string[] expectedLdsContents = { "[OtherStuff]", //Environment.NewLine + "[General]", "codepage=65001", "font=Wingdings", "size=14", "name=French", "RTL=F" }; writer.VerifyOutput(expectedLdsContents); }
public void UpdateParatextLdsFile_UpdateFontAndSizeAndAddRTL() { if (File.Exists("test.lds")) File.Delete("test.lds"); int wsHvo = Cache.DefaultVernWs; LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo); vernWs.Name.UserDefaultWritingSystem = "French"; DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry(); StyleInfoTable styleTable = new StyleInfoTable("Normal", Cache.LanguageWritingSystemFactoryAccessor); styleTable.Add("Normal", normalEntry); normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000; normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings"; string ldsContentsOrig = "[General]" + Environment.NewLine + "codepage=65001" + Environment.NewLine + "DialogFontsize=0" + Environment.NewLine + "LowerCaseLetters=" + Environment.NewLine + "NoCaseLetters=" + Environment.NewLine + "UpperCaseLetters=" + Environment.NewLine + "errors=" + Environment.NewLine + "font=Arial" + Environment.NewLine + "name=French" + Environment.NewLine + "separator=" + Environment.NewLine + "size=32" + Environment.NewLine + Environment.NewLine + "[Checking]" + Environment.NewLine + Environment.NewLine + "[Characters]" + Environment.NewLine + Environment.NewLine + "[Punctuation]" + Environment.NewLine + "diacritics=" + Environment.NewLine + "medial="; DummyFileWriter writer = new DummyFileWriter(); writer.Open("test.lds"); ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache); ReflectionHelper.CallMethod(ldsAccessor, "UpdateLdsContents", ldsContentsOrig, normalEntry, Cache.DefaultVernWs, writer); // Verify the .lds file string[] expectedLdsContents = { "[General]", "codepage=65001", "DialogFontsize=0", "LowerCaseLetters=", "NoCaseLetters=", "UpperCaseLetters=", "errors=", "font=Wingdings", "name=French", "separator=", "size=14", "RTL=F", //Environment.NewLine, string.Empty "[Checking]", //Environment.NewLine, string.Empty "[Characters]", //Environment.NewLine, string.Empty "[Punctuation]", "diacritics=", "medial=" }; ((DummyFileWriter)writer).VerifyOutput(expectedLdsContents); }
public void WriteParatextLdsFile_BT() { if (File.Exists("test.lds")) File.Delete("test.lds"); int wsUrduBT = InMemoryFdoCache.s_wsHvos.Ur; IWritingSystem btWs = Cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(wsUrduBT); string btWsName = btWs.get_UiName(Cache.DefaultUserWs); DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry(); StyleInfoTable styleTable = new StyleInfoTable("Normal", Cache.LanguageWritingSystemFactoryAccessor); styleTable.Add("Normal", normalEntry); normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000; normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings"; DummyFileWriter fileWriterLDS = new DummyFileWriter(); ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache); ReflectionHelper.CallMethod(ldsAccessor, "WriteParatextLdsFile", "test.lds", wsUrduBT, normalEntry, fileWriterLDS); // Verify the .lds file string[] expectedLds = { "[General]", "codepage=65001", "RTL=T", "font=Wingdings", "name=" + btWs.get_UiName(Cache.DefaultUserWs), "size=14", string.Empty, "[Checking]", string.Empty, "[Characters]", string.Empty, "[Punctuation]" }; fileWriterLDS.VerifyOutput(expectedLds); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Open the file. This is virtual so it can be replaced in testing with an /// in-memory file writer. /// </summary> /// <param name="fileName"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ protected override FileWriter OpenFile(string fileName) { DummyFileWriter writer = new DummyFileWriter(); writer.Open(fileName); return writer; }