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 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);
        }