Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <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);
        }
        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 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);
		}
Exemplo n.º 6
0
		/// ------------------------------------------------------------------------------------
		/// <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;
		}