public void UpdateParatextLdsFile_GeneralSectionMissing()
		{
			IWritingSystem vernWs = Cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem;

			DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
			m_exporter.UsfmEntries.Add(ScrStyleNames.Normal, normalEntry);
			normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
			normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

			string ldsContentsOrig =
				"[OtherStuff]";

			ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);
			using (TextWriter tw = FileUtils.OpenFileForWrite("test.lds", Encoding.ASCII))
				ldsAccessor.UpdateLdsContents(ldsContentsOrig, normalEntry, Cache.DefaultVernWs, tw);

			// Verify the .lds file
			string[] expectedLdsContents =
			{
				"[OtherStuff]",
				"",
				"[General]",
				"codepage=" + ParatextSsfFileAccessor.kUnicodeEncoding,
				"font=Wingdings",
				"size=14",
				"name=French",
				"RTL=F"
			};

			using (DummyFileWriter writer = new DummyFileWriter())
			{
				writer.Open("test.lds");
				writer.VerifyOutput(expectedLdsContents);
			}
		}
		public void UpdateParatextLdsFile_UpdateFontAndSizeAndAddRTL()
		{
			IWritingSystem vernWs = Cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem;

			DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
			m_exporter.UsfmEntries.Add(ScrStyleNames.Normal, normalEntry);
			normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
			normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

			string ldsContentsOrig =
				"[General]" + Environment.NewLine +
				"codepage=" + ParatextSsfFileAccessor.kUnicodeEncoding + 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=";

			ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);
			using (TextWriter tw = FileUtils.OpenFileForWrite("test.lds", Encoding.ASCII))
				ldsAccessor.UpdateLdsContents(ldsContentsOrig, normalEntry, Cache.DefaultVernWs, tw);

			// Verify the .lds file
			string[] expectedLdsContents =
			{
				"[General]",
				"codepage=" + ParatextSsfFileAccessor.kUnicodeEncoding,
				"DialogFontsize=0",
				"LowerCaseLetters=",
				"NoCaseLetters=",
				"UpperCaseLetters=",
				"errors=",
				"font=Wingdings",
				"name=French",
				"separator=",
				"size=14",
				"RTL=F",
				"",
				"[Checking]",
				"",
				"[Characters]",
				"",
				"[Punctuation]",
				"diacritics=",
				"medial="
			};
			using (DummyFileWriter writer = new DummyFileWriter())
			{
				writer.Open("test.lds");
				writer.VerifyOutput(expectedLdsContents);
			}
		}
		public void WriteParatextLdsFile_BT()
		{

			IWritingSystem wsUr = Cache.ServiceLocator.WritingSystemManager.Get("ur");
			wsUr.RightToLeftScript = true;
			string btWsName = wsUr.DisplayLabel;

			DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
			m_exporter.UsfmEntries.Add(ScrStyleNames.Normal, normalEntry);
			normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
			normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

			ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);
			ldsAccessor.WriteParatextLdsFile("test.lds", wsUr.Handle, normalEntry);

			// Verify the .lds file
			string[] expectedLds =
			{
				"[General]",
				"codepage=" + ParatextSsfFileAccessor.kUnicodeEncoding,
				"RTL=T",
				"font=Wingdings",
				"name=" + btWsName,
				"size=14",
				string.Empty,
				"[Checking]",
				string.Empty,
				"[Characters]",
				string.Empty,
				"[Punctuation]"
			};

			using (DummyFileWriter actualLds = new DummyFileWriter())
			{
				actualLds.Open("test.lds");
				actualLds.VerifyOutput(expectedLds);
			}
		}
		public void UpdateParatextLdsFile_FileMissing()
		{
			ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);
			bool actualReturn = ldsAccessor.UpdateLdsFile("c:\\whatever\\wherever\\whenever\\yeah.lds", new DummyUsfmStyEntry(),
				Cache.DefaultVernWs);

			Assert.IsFalse(actualReturn, "Updating file should have failed for missing file.");
		}
		public void WriteParatextLdsFile()
		{

			IWritingSystem vernWs = Cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem;

			DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
			m_exporter.UsfmEntries.Add(ScrStyleNames.Normal, normalEntry);
			normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
			normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

			ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);
			ldsAccessor.WriteParatextLdsFile("test.lds", Cache.DefaultVernWs, normalEntry);

			// Verify the .lds file
			string[] expectedLds =
			{
				"[General]",
				"codepage=" + ParatextSsfFileAccessor.kUnicodeEncoding,
				"RTL=F",
				"font=Wingdings",
				"name=French",
				"size=14",
				string.Empty,
				"[Checking]",
				string.Empty,
				"[Characters]",
				string.Empty,
				"[Punctuation]"
			};

			using (DummyFileWriter actualLds = new DummyFileWriter())
			{
				actualLds.Open("test.lds");
				actualLds.VerifyOutput(expectedLds);
			}
		}