当前位置: 首页>>代码示例>>C#>>正文


C# TestEnvironment.FilePath方法代码示例

本文整理汇总了C#中TestEnvironment.FilePath方法的典型用法代码示例。如果您正苦于以下问题:C# TestEnvironment.FilePath方法的具体用法?C# TestEnvironment.FilePath怎么用?C# TestEnvironment.FilePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestEnvironment的用法示例。


在下文中一共展示了TestEnvironment.FilePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Roundtrip_LdmlInvalidStandardCollation

		public void Roundtrip_LdmlInvalidStandardCollation()
		{
			using (var environment = new TestEnvironment())
			{
				const string icuRules =
					"&&&B<t<<<T<s<<<S<e<<<E\r\n\t\t\t\t&C<k<<<K<x<<<X<i<<<I\r\n\t\t\t\t&D<q<<<Q<r<<<R\r\n\t\t\t\t&G<o<<<O\r\n\t\t\t\t&W<h<<<H";
				var cd = new IcuRulesCollationDefinition("standard")
				{
					IcuRules = icuRules,
					CollationRules = icuRules,
					IsValid = false
				};

				var wsToLdml = new WritingSystemDefinition("aa", "Latn", "", "");
				wsToLdml.Collations.Add(cd);
				var ldmlAdaptor = new LdmlDataMapper(new TestWritingSystemFactory());
				ldmlAdaptor.Write(environment.FilePath("test.ldml"), wsToLdml, null);

				XElement ldmlElem = XElement.Load(environment.FilePath("test.ldml"));
				XElement collationsElem = ldmlElem.Element("collations");
				XElement defaultCollationElem = collationsElem.Element("defaultCollation");
				XElement collationElem = collationsElem.Element("collation");
				Assert.That((string)defaultCollationElem, Is.EqualTo("standard"));
				Assert.That((string)collationElem.Attribute("type"), Is.EqualTo("standard"));
				Assert.That((string)collationElem, Is.EqualTo(icuRules.Replace("\r\n", "\n")));
				// Verify comment written about being unable to parse ICU rule
				const string expectedComment = "'Unable to parse the ICU rules with ICU version'";
				AssertThatXmlIn.File(environment.FilePath("test.ldml"))
					.HasAtLeastOneMatchForXpath(string.Format("/ldml/collations/collation/comment()[contains(.,{0})]", expectedComment));

				var wsFromLdml = new WritingSystemDefinition();
				ldmlAdaptor.Read(environment.FilePath("test.ldml"), wsFromLdml);
				Assert.That(wsFromLdml.Collations.First().ValueEquals(cd));
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:35,代码来源:LdmlDataMapperTests.cs

示例2: Roundtrip_LdmlSimpleCollation

		public void Roundtrip_LdmlSimpleCollation()
		{
			using (var environment = new TestEnvironment())
			{
				const string simpleRules =
					"\r\n\t\t\t\t\ta/A\r\n\t\t\t\t\tb/B\r\n\t\t\t\t\tt/T\r\n\t\t\t\t\ts/S\r\n\t\t\t\t\tc/C\r\n\t\t\t\t\tk/K\r\n\t\t\t\t\tx/X\r\n\t\t\t\t\ti/I\r\n\t\t\t\t\td/D\r\n\t\t\t\t\tq/Q\r\n\t\t\t\t\tr/R\r\n\t\t\t\t\te/E\r\n\t\t\t\t\tf/F\r\n\t\t\t\t\tg/G\r\n\t\t\t\t\to/O\r\n\t\t\t\t\tj/J\r\n\t\t\t\t\tl/L\r\n\t\t\t\t\tm/M\r\n\t\t\t\t\tn/N\r\n\t\t\t\t\tp/P\r\n\t\t\t\t\tu/U\r\n\t\t\t\t\tv/V\r\n\t\t\t\t\tw/W\r\n\t\t\t\t\th/H\r\n\t\t\t\t\ty/Y\r\n\t\t\t\t\tz/Z\r\n\t\t\t\t";
				const string icuRules =
					"&[before 1] [first regular]  < a\\/A < b\\/B < t\\/T < s\\/S < c\\/C < k\\/K < x\\/X < i\\/I < d\\/D < q\\/Q < r\\/R < e\\/E < f\\/F < g\\/G < o\\/O < j\\/J < l\\/L < m\\/M < n\\/N < p\\/P < u\\/U < v\\/V < w\\/W < h\\/H < y\\/Y < z\\/Z";
				var cd = new SimpleRulesCollationDefinition("standard")
				{
					SimpleRules = simpleRules,
					CollationRules = icuRules,
					IsValid = true
				};
				var wsToLdml = new WritingSystemDefinition("aa", "Latn", "", "");
				wsToLdml.Collations.Add(cd);

				var ldmlAdaptor = new LdmlDataMapper(new TestWritingSystemFactory());
				ldmlAdaptor.Write(environment.FilePath("test.ldml"), wsToLdml, null);
				XElement ldmlElem = XElement.Load(environment.FilePath("test.ldml"));
				XElement collationsElem = ldmlElem.Element("collations");
				XElement defaultCollationElem = collationsElem.Element("defaultCollation");
				XElement collationElem = collationsElem.Element("collation");
				XElement crElem = collationElem.Element("cr");
				XElement simpleElem = collationElem.Element("special").Element(Sil + "simple");
				Assert.That((string)defaultCollationElem, Is.EqualTo("standard"));
				Assert.That((string)collationElem.Attribute("type"), Is.EqualTo("standard"));
				Assert.That((string)crElem, Is.EqualTo(icuRules.Replace("\r\n", "\n")));
				Assert.That((string)simpleElem, Is.EqualTo(simpleRules.Replace("\r\n", "\n")));

				var wsFromLdml = new WritingSystemDefinition();
				ldmlAdaptor.Read(environment.FilePath("test.ldml"), wsFromLdml);

				Assert.That(wsFromLdml.Collations.First().ValueEquals(cd));
				Assert.That(wsFromLdml.DefaultCollation.ValueEquals(cd));
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:37,代码来源:LdmlDataMapperTests.cs

示例3: Migrate_LdmlIsFlexPrivateUseFormatDefaultMigrator_FileIsUpdated

		public void Migrate_LdmlIsFlexPrivateUseFormatDefaultMigrator_FileIsUpdated()
		{
			using (var environment = new TestEnvironment())
			{
				var originalFilecontent = LdmlContentForTests.Version0("x-en", "Zxxx", "US", "1901-x-audio");
				environment.WriteLdmlFile("test.ldml", originalFilecontent);
				var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback, WritingSystemCompatibility.Strict);
				migrator.Migrate();
				AssertThatLdmlMatches("qaa", "Zxxx", "US", "1901-x-en-audio", environment.FilePath("qaa-Zxxx-US-1901-x-en-audio.ldml"));
			}
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:11,代码来源:LdmlInFolderWritingSystemRepositoryMigratorTests.cs

示例4: Roundtrip_LdmlStandardCollation

		public void Roundtrip_LdmlStandardCollation()
		{
			using (var environment = new TestEnvironment())
			{
				const string icuRules =
					"&B<t<<<T<s<<<S<e<<<E\r\n\t\t\t\t&C<k<<<K<x<<<X<i<<<I\r\n\t\t\t\t&D<q<<<Q<r<<<R\r\n\t\t\t\t&G<o<<<O\r\n\t\t\t\t&W<h<<<H";
				var cd = new IcuRulesCollationDefinition("standard")
				{
					IcuRules = icuRules,
					CollationRules = icuRules,
					IsValid = true
				};

				var wsToLdml = new WritingSystemDefinition("aa", "Latn", "", "");
				wsToLdml.Collations.Add(cd);
				var ldmlAdaptor = new LdmlDataMapper(new TestWritingSystemFactory());
				ldmlAdaptor.Write(environment.FilePath("test.ldml"), wsToLdml, null);

				XElement ldmlElem = XElement.Load(environment.FilePath("test.ldml"));
				XElement collationsElem = ldmlElem.Element("collations");
				XElement defaultCollationElem = collationsElem.Element("defaultCollation");
				XElement collationElem = collationsElem.Element("collation");
				Assert.That((string)defaultCollationElem, Is.EqualTo("standard"));
				Assert.That((string) collationElem.Attribute("type"), Is.EqualTo("standard"));
				Assert.That((string) collationElem, Is.EqualTo(icuRules.Replace("\r\n", "\n")));
				
				var wsFromLdml = new WritingSystemDefinition();
				ldmlAdaptor.Read(environment.FilePath("test.ldml"), wsFromLdml);
				Assert.That(wsFromLdml.Collations.First().ValueEquals(cd));
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:31,代码来源:LdmlDataMapperTests.cs

示例5: Write_UnknownKeyboard_NotWrittenToLdml

		public void Write_UnknownKeyboard_NotWrittenToLdml()
		{
			using (var environment = new TestEnvironment())
			{
				var urls = new List<string>
				{
					"http://wirl.scripts.sil.org/keyman",
					"http://scripts.sil.org/cms/scripts/page.php?item_id=keyman9"
				};
				IKeyboardDefinition kbd1 = Keyboard.Controller.CreateKeyboard("Compiled Keyman9", KeyboardFormat.CompiledKeyman, urls);
				IKeyboardDefinition kbd2 = Keyboard.Controller.CreateKeyboard("Unknown System Keyboard", KeyboardFormat.Unknown, urls);

				var wsToLdml = new WritingSystemDefinition("en", "Latn", "", "");
				wsToLdml.KnownKeyboards.Add(kbd1);
				wsToLdml.KnownKeyboards.Add(kbd2);
				var ldmlAdaptor = new LdmlDataMapper(new TestWritingSystemFactory());
				ldmlAdaptor.Write(environment.FilePath("test.ldml"), wsToLdml, null);
				AssertThatXmlIn.File(environment.FilePath("test.ldml"))
					.HasAtLeastOneMatchForXpath(
						"/ldml/special/sil:external-resources/sil:kbd[@id='Compiled Keyman9' and @type='kmx']/sil:url[text()='http://wirl.scripts.sil.org/keyman']",
						environment.NamespaceManager);
				AssertThatXmlIn.File(environment.FilePath("test.ldml"))
					.HasAtLeastOneMatchForXpath(
						"/ldml/special/sil:external-resources/sil:kbd[@id='Compiled Keyman9' and @type='kmx']/sil:url[text()='http://scripts.sil.org/cms/scripts/page.php?item_id=keyman9']",
						environment.NamespaceManager);
				AssertThatXmlIn.File(environment.FilePath("test.ldml"))
					.HasNoMatchForXpath(
						"/ldml/special/sil:external-resources/sil:kbd[@id='Unknown System Keyboard']",
						environment.NamespaceManager);

				var wsFromLdml = new WritingSystemDefinition();
				ldmlAdaptor.Read(environment.FilePath("test.ldml"), wsFromLdml);
				Assert.That(wsFromLdml.KnownKeyboards.First(), Is.EqualTo(kbd1));
				Assert.That(wsFromLdml.KnownKeyboards.Count, Is.EqualTo(1));
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:36,代码来源:LdmlDataMapperTests.cs

示例6: Write_SystemCollationDefinition_NotWrittenToLdml

		public void Write_SystemCollationDefinition_NotWrittenToLdml()
		{
			using (var environment = new TestEnvironment())
			{
				var wsToLdml = new WritingSystemDefinition("en", "Latn", "", "");
				wsToLdml.DefaultCollation = new SystemCollationDefinition { LanguageTag = "en-US" };
				wsToLdml.Collations.Add(new IcuRulesCollationDefinition("standard"));
				var ldmlAdaptor = new LdmlDataMapper(new TestWritingSystemFactory());
				ldmlAdaptor.Write(environment.FilePath("test.ldml"), wsToLdml, null);
				AssertThatXmlIn.File(environment.FilePath("test.ldml"))
					.HasAtLeastOneMatchForXpath(
						"/ldml/collations/collation[@type='standard']",
						environment.NamespaceManager);
				AssertThatXmlIn.File(environment.FilePath("test.ldml"))
					.HasNoMatchForXpath(
						"/ldml/collations/collation[@type='system']",
						environment.NamespaceManager);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:19,代码来源:LdmlDataMapperTests.cs

示例7: Roundtrip_VariantName

		public void Roundtrip_VariantName()
		{
			using (var environment = new TestEnvironment())
			{
				var wsToLdml = new WritingSystemDefinition("en", "Latn", "GB", "x-test")
				{
					VersionNumber = "$Revision$",
					VersionDescription = "Identity version description",
					WindowsLcid = "1036",
					DefaultRegion = "US"
				};
				wsToLdml.Variants[0] = new VariantSubtag(wsToLdml.Variants[0], "test0");
				var ldmlAdaptor = new LdmlDataMapper(new TestWritingSystemFactory());

				ldmlAdaptor.Write(environment.FilePath("test.ldml"), wsToLdml, null);
				AssertThatXmlIn.File(environment.FilePath("test.ldml")).HasAtLeastOneMatchForXpath("/ldml/identity/language[@type='en']");
				AssertThatXmlIn.File(environment.FilePath("test.ldml")).HasNoMatchForXpath("/ldml/identity/script");
				AssertThatXmlIn.File(environment.FilePath("test.ldml")).HasAtLeastOneMatchForXpath("/ldml/identity/territory[@type='GB']");
				AssertThatXmlIn.File(environment.FilePath("test.ldml")).HasAtLeastOneMatchForXpath("/ldml/identity/variant[@type='x-test']");
				AssertThatXmlIn.File(environment.FilePath("test.ldml")).HasAtLeastOneMatchForXpath("/ldml/identity/version[@number='$Revision$' and text()='Identity version description']");
				AssertThatXmlIn.File(environment.FilePath("test.ldml")).HasAtLeastOneMatchForXpath("/ldml/identity/special/sil:identity[@windowsLCID='1036' and @defaultRegion='US' and @variantName='test0']", environment.NamespaceManager);

				var wsFromLdml = new WritingSystemDefinition();
				ldmlAdaptor.Read(environment.FilePath("test.ldml"), wsFromLdml);
				Assert.That(wsFromLdml.VersionNumber, Is.EqualTo("$Revision$"));
				Assert.That(wsFromLdml.VersionDescription, Is.EqualTo("Identity version description"));
				Assert.That(wsFromLdml.LanguageTag, Is.EqualTo("en-GB-x-test"));
				Assert.That(wsFromLdml.WindowsLcid, Is.EqualTo("1036"));
				Assert.That(wsFromLdml.DefaultRegion, Is.EqualTo("US"));
				int index = IetfLanguageTag.GetIndexOfFirstNonCommonPrivateUseVariant(wsFromLdml.Variants);
				Assert.That(index, Is.EqualTo(0));
				Assert.That(wsFromLdml.Variants[index].Name, Is.EqualTo("test0"));
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:34,代码来源:LdmlDataMapperTests.cs

示例8: Roundtrip_LdmlFont

		public void Roundtrip_LdmlFont()
		{
			using (var environment = new TestEnvironment())
			{
				var fd = new FontDefinition("Padauk")
				{
					RelativeSize = 2.1f,
					MinVersion = "3.1.4",
					Features = "order=3 children=2 color=red createDate=1996",
					Language = "en",
					Engines = FontEngines.Graphite | FontEngines.OpenType,
					OpenTypeLanguage = "abcd",
					Roles = FontRoles.Default | FontRoles.Emphasis,
					Subset = "unknown"
				};
				fd.Urls.Add("http://wirl.scripts.sil.org/padauk");
				fd.Urls.Add("http://scripts.sil.org/cms/scripts/page.php?item_id=padauk");

				var wsToLdml = new WritingSystemDefinition("en", "Latn", "", "");
				wsToLdml.Fonts.Add(fd);

				var ldmlAdaptor = new LdmlDataMapper(new TestWritingSystemFactory());
				ldmlAdaptor.Write(environment.FilePath("test.ldml"), wsToLdml, null);
				AssertThatXmlIn.File(environment.FilePath("test.ldml"))
					.HasAtLeastOneMatchForXpath("/ldml/special/sil:external-resources/sil:font[@name='Padauk' and @types='default emphasis' and @size='2.1' and @minversion='3.1.4' and @features='order=3 children=2 color=red createDate=1996' and @lang='en' and @otlang='abcd' and @subset='unknown']/sil:url[text()='http://wirl.scripts.sil.org/padauk']", environment.NamespaceManager);
				AssertThatXmlIn.File(environment.FilePath("test.ldml"))
					.HasAtLeastOneMatchForXpath("/ldml/special/sil:external-resources/sil:font[@name='Padauk' and @types='default emphasis' and @size='2.1' and @minversion='3.1.4' and @features='order=3 children=2 color=red createDate=1996' and @lang='en' and @otlang='abcd' and @subset='unknown']/sil:url[text()='http://scripts.sil.org/cms/scripts/page.php?item_id=padauk']", environment.NamespaceManager);


				var wsFromLdml = new WritingSystemDefinition();
				ldmlAdaptor.Read(environment.FilePath("test.ldml"), wsFromLdml);

				Assert.That(wsFromLdml.Fonts.First().ValueEquals(fd));
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:35,代码来源:LdmlDataMapperTests.cs

示例9: Migrate_DateModified_IsLaterThanBeforeMigration

		public void Migrate_DateModified_IsLaterThanBeforeMigration()
		{
			using (var environment = new TestEnvironment())
			{
				environment.WriteLdmlFile(
					"test.ldml",
					LdmlContentForTests.Version0WithAllSortsOfDatathatdoesNotNeedSpecialAttention("", "", "", ""));

				var wsV0 = new WritingSystemDefinitionV0();
				new LdmlAdaptorV0().Read(environment.FilePath("test.ldml"), wsV0);
				DateTime dateBeforeMigration = wsV0.DateModified;

				var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback);
				migrator.Migrate();

				var wsV3 = new WritingSystemDefinition();
				new LdmlDataMapper(new TestWritingSystemFactory()).Read(environment.MappedFilePath("test.ldml"), wsV3);
				DateTime dateAfterMigration = wsV3.DateModified;
				Assert.IsTrue(dateAfterMigration > dateBeforeMigration);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:21,代码来源:LdmlInFolderWritingSystemRepositoryMigratorTests.cs

示例10: Migrate_OriginalFileContainsNoCollationInfo_StandardCollationInfoIsMigrated

		public void Migrate_OriginalFileContainsNoCollationInfo_StandardCollationInfoIsMigrated()
		{
			using (var environment = new TestEnvironment())
			{
				environment.WriteLdmlFile(
					"test.ldml",
					LdmlContentForTests.Version0WithCollationInfo(WritingSystemDefinitionV0.SortRulesType.DefaultOrdering));
				var wsV0 = new WritingSystemDefinitionV0();
				new LdmlAdaptorV0().Read(environment.FilePath("test.ldml"), wsV0);

				var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback);
				migrator.Migrate();

				var wsV3 = new WritingSystemDefinition();
				new LdmlDataMapper(null).Read(environment.MappedFilePath("test.ldml"), wsV3);
				var cdV3 = (IcuRulesCollationDefinition) wsV3.Collations.First();
				Assert.IsNullOrEmpty(wsV0.SortRules);
				Assert.IsNullOrEmpty(cdV3.CollationRules);
				Assert.That(cdV3.Type, Is.EqualTo("standard"));
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:21,代码来源:LdmlInFolderWritingSystemRepositoryMigratorTests.cs

示例11: Migrate_OriginalFileContainsCustomIcuCollationInfo_CollationInfoIsMigrated

		public void Migrate_OriginalFileContainsCustomIcuCollationInfo_CollationInfoIsMigrated()
		{
			using (var environment = new TestEnvironment())
			{
				environment.WriteLdmlFile(
					"test.ldml",
					LdmlContentForTests.Version0WithCollationInfo(WritingSystemDefinitionV0.SortRulesType.CustomICU));
				var wsV0 = new WritingSystemDefinitionV0();
				new LdmlAdaptorV0().Read(environment.FilePath("test.ldml"), wsV0);

				var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback);
				migrator.Migrate();

				var wsV3 = new WritingSystemDefinition();
				new LdmlDataMapper(null).Read(environment.MappedFilePath("test.ldml"), wsV3);
				var cdV3 = (IcuRulesCollationDefinition) wsV3.Collations.First();
				Assert.AreEqual(wsV0.SortRules, cdV3.CollationRules);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:19,代码来源:LdmlInFolderWritingSystemRepositoryMigratorTests.cs

示例12: Migrate_OriginalFileContainsSystemCollationInfo_CollationInfoIsMigrated

		public void Migrate_OriginalFileContainsSystemCollationInfo_CollationInfoIsMigrated()
		{
			using (var environment = new TestEnvironment())
			{
				environment.WriteLdmlFile(
					"test.ldml",
					LdmlContentForTests.Version0WithSystemCollationInfo());
				var wsV0 = new WritingSystemDefinitionV0();
				new LdmlAdaptorV0().Read(environment.FilePath("test.ldml"), wsV0);

				var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback);
				migrator.Migrate();
				var repo = new TestLdmlInFolderWritingSystemRepository(environment.LdmlPath);
				migrator.ResetRemovedProperties(repo);

				WritingSystemDefinition ws = repo.Get("de");
				var scd = new SystemCollationDefinition {LanguageTag = "de"};
				Assert.That(ws.DefaultCollation.ValueEquals(scd), Is.True);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:20,代码来源:LdmlInFolderWritingSystemRepositoryMigratorTests.cs

示例13: Migrate_OriginalFileContainsCustomIcuCollationInfo_CollationInfoIsMigrated

		public void Migrate_OriginalFileContainsCustomIcuCollationInfo_CollationInfoIsMigrated()
		{
			using (var environment = new TestEnvironment())
			{
				environment.WriteLdmlFile(
					"test.ldml",
					LdmlContentForTests.Version0WithCollationInfo(WritingSystemDefinitionV0.SortRulesType.CustomICU));
				var wsV0 = new WritingSystemDefinitionV0();
				new LdmlAdaptorV0().Read(environment.FilePath("test.ldml"), wsV0);

				var migrator = new LdmlInFolderWritingSystemRepositoryMigrator(environment.LdmlPath, environment.OnMigrateCallback);
				migrator.Migrate();

				var wsV1 = new WritingSystemDefinitionV1();
				new LdmlAdaptorV1().Read(environment.MappedFilePath("test.ldml"), wsV1);
				Assert.AreEqual(wsV0.SortRules, wsV1.SortRules);
				Assert.AreEqual(Enum.GetName(typeof(WritingSystemDefinitionV0.SortRulesType), wsV0.SortUsing), Enum.GetName(typeof(WritingSystemDefinitionV1.SortRulesType), wsV0.SortUsing));
			}
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:19,代码来源:LdmlInFolderWritingSystemRepositoryMigratorTests.cs

示例14: Roundtrip_LdmlSimpleCollationNeedsCompiling

		public void Roundtrip_LdmlSimpleCollationNeedsCompiling()
		{
			using (var environment = new TestEnvironment())
			{
				const string simpleRules =
					"\r\n\t\t\t\t\t\\!/A\r\n\t\t\t\t\tb/B\r\n\t\t\t\t\tt/T\r\n\t\t\t\t\ts/S\r\n\t\t\t\t\tc/C\r\n\t\t\t\t\tk/K\r\n\t\t\t\t\tx/X\r\n\t\t\t\t\ti/I\r\n\t\t\t\t\td/D\r\n\t\t\t\t\tq/Q\r\n\t\t\t\t\tr/R\r\n\t\t\t\t\te/E\r\n\t\t\t\t\tf/F\r\n\t\t\t\t\tg/G\r\n\t\t\t\t\to/O\r\n\t\t\t\t\tj/J\r\n\t\t\t\t\tl/L\r\n\t\t\t\t\tm/M\r\n\t\t\t\t\tn/N\r\n\t\t\t\t\tp/P\r\n\t\t\t\t\tu/U\r\n\t\t\t\t\tv/V\r\n\t\t\t\t\tw/W\r\n\t\t\t\t\th/H\r\n\t\t\t\t\ty/Y\r\n\t\t\t\t\tz/Z\r\n\t\t\t\t";
				var cd = new SimpleRulesCollationDefinition("standard")
				{
					SimpleRules = simpleRules,
				};
				var wsToLdml = new WritingSystemDefinition("aa", "Latn", "", "");
				wsToLdml.Collations.Add(cd);

				var ldmlAdaptor = new LdmlDataMapper(new TestWritingSystemFactory());
				ldmlAdaptor.Write(environment.FilePath("test.ldml"), wsToLdml, null);
				XElement ldmlElem = XElement.Load(environment.FilePath("test.ldml"));
				XElement collationsElem = ldmlElem.Element("collations");
				XElement defaultCollationElem = collationsElem.Element("defaultCollation");
				XElement collationElem = collationsElem.Element("collation");
				XElement specialElem = collationElem.Element("special");
				XElement simpleElem = specialElem.Element(Sil + "simple");
				Assert.That((string)defaultCollationElem, Is.EqualTo("standard"));
				Assert.That((string)collationElem.Attribute("type"), Is.EqualTo("standard"));
				Assert.That((string)specialElem.Attribute(Sil + "needsCompiling"), Is.EqualTo("true"));
				Assert.That((string)simpleElem, Is.EqualTo(simpleRules.Replace("\r\n", "\n")));

				var validatedCd = new SimpleRulesCollationDefinition("standard")
				{
					SimpleRules = simpleRules
				};
				// When the LDML reader parses the invalid rules, it will validate and regenerate icu rules
				var wsFromLdml = new WritingSystemDefinition();
				ldmlAdaptor.Read(environment.FilePath("test.ldml"), wsFromLdml);

				Assert.That(wsFromLdml.Collations.First().ValueEquals(validatedCd));
				Assert.That(wsFromLdml.DefaultCollation.ValueEquals(validatedCd));
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:38,代码来源:LdmlDataMapperTests.cs

示例15: Roundtrip_LdmlLayout

		public void Roundtrip_LdmlLayout()
		{
			using (var environment = new TestEnvironment())
			{
				// Write/Read RightToLeftScript is false
				var wsToLdml = new WritingSystemDefinition("en", "Latn", "", "")
				{
					RightToLeftScript = false
				};
				var ldmlAdaptor = new LdmlDataMapper(new TestWritingSystemFactory());
				ldmlAdaptor.Write(environment.FilePath("test.ldml"), wsToLdml, null);
				AssertThatXmlIn.File(environment.FilePath("test.ldml")).HasAtLeastOneMatchForXpath("/ldml/layout/orientation/characterOrder[text()='left-to-right']");

				var wsFromLdml = new WritingSystemDefinition();
				ldmlAdaptor.Read(environment.FilePath("test.ldml"), wsFromLdml);
				Assert.That(wsFromLdml.RightToLeftScript, Is.False);

				// Write/Read RightToLeftScript is true
				wsToLdml.RightToLeftScript = true;
				ldmlAdaptor.Write(environment.FilePath("test.ldml"), wsToLdml, null);
				AssertThatXmlIn.File(environment.FilePath("test.ldml")).HasAtLeastOneMatchForXpath("/ldml/layout/orientation/characterOrder[text()='right-to-left']");

				ldmlAdaptor.Read(environment.FilePath("test.ldml"), wsFromLdml);
				Assert.That(wsFromLdml.RightToLeftScript, Is.True);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:26,代码来源:LdmlDataMapperTests.cs


注:本文中的TestEnvironment.FilePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。