• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# LiftExportAsFragmentTestSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中LiftExportAsFragmentTestSession的典型用法代码示例。如果您正苦于以下问题:C# LiftExportAsFragmentTestSession类的具体用法?C# LiftExportAsFragmentTestSession怎么用?C# LiftExportAsFragmentTestSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LiftExportAsFragmentTestSession类属于命名空间,在下文中一共展示了LiftExportAsFragmentTestSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: VariantWith2Traits

		public void VariantWith2Traits()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var variant = new LexVariant();
				variant.SetAlternative("etr", "one");
				variant.Traits.Add(new LexTrait("a", "A"));
				variant.Traits.Add(new LexTrait("b", "B"));
				session.LiftWriter.AddVariant(variant);
				session.LiftWriter.End();
				AssertHasOneMatch("variant/trait[@name='a' and @value='A']", session);
				AssertHasOneMatch("variant/trait[@name='b' and @value='B']", session);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:14,代码来源:LiftWriterTests.cs


示例2: Add_CultureUsesPeriodForTimeSeparator_DateAttributesOutputWithColon

		public void Add_CultureUsesPeriodForTimeSeparator_DateAttributesOutputWithColon()
		{
			var culture = new CultureInfo("en-US");
			culture.DateTimeFormat.TimeSeparator = ".";

			Thread.CurrentThread.CurrentCulture = culture;

			using (var session = new LiftExportAsFragmentTestSession())
			{
				LexEntry entry = session.CreateItem();
				entry.LexicalForm["test"] = "lexicalForm";
				// make dateModified different than dateCreated
				//_lexEntryRepository.SaveItem(entry);
				session.LiftWriter.Add(entry);
				session.LiftWriter.End();
				string result = session.StringBuilder.ToString();
				AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath(
					String.Format("//entry[@dateModified=\"{0}\"]",
								  entry.ModificationTime.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture))
					);
				Assert.IsTrue(result.Contains(":"), "should contain colons");
				Assert.IsFalse(result.Contains("."), "should not contain periods");
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:24,代码来源:LiftWriterTests.cs


示例3: ExampleSentenceWithTranslation

		public void ExampleSentenceWithTranslation()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var example = new LexExampleSentence();
				example.Sentence["blue"] = "ocean's eleven";
				example.Sentence["red"] = "red sunset tonight";
				example.Translation["green"] = "blah blah";
				session.LiftWriter.Add(example);
				var outPut = session.OutputString();
				AssertEqualsCanonicalString(
					"<example><form lang=\"blue\"><text>ocean's eleven</text></form><form lang=\"red\"><text>red sunset tonight</text></form><translation><form lang=\"green\"><text>blah blah</text></form></translation></example>", outPut);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:14,代码来源:LiftWriterTests.cs


示例4: EntryGuid

		public void EntryGuid()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				LexEntry entry = session.CreateItem();
				session.LiftWriter.Add(entry);
				session.LiftWriter.End();
				string result = session.StringBuilder.ToString();
				AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath(String.Format("//entry[@guid=\"{0}\"]", entry.Guid));
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:11,代码来源:LiftWriterTests.cs


示例5: EntryHasDateCreated

		public void EntryHasDateCreated()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				LexEntry entry = session.CreateItem();
				session.LiftWriter.Add(entry);
				session.LiftWriter.End();
				string result = session.StringBuilder.ToString();
				AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath(
					String.Format("//entry[@dateCreated=\"{0}\"]", entry.CreationTime.ToString("yyyy-MM-ddTHH:mm:ssZ"))
				);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:13,代码来源:LiftWriterTests.cs


示例6: Entry_EntryHasIdWithInvalidXMLCharacters_CharactersEscaped

		public void Entry_EntryHasIdWithInvalidXMLCharacters_CharactersEscaped()
		{
			const string expected = "id=\"&lt;&gt;&amp;&quot;'\"";
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var entry = session.CreateItem();
				// technically the only invalid characters in an attribute are & < and " (when surrounded by ")
				entry.Id = "<>&\"\'";
				//_lexEntryRepository.SaveItem(entry);
				session.LiftWriter.Add(entry);
				string result = session.OutputString();
				Assert.IsTrue(result.Contains(expected));
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:14,代码来源:LiftWriterTests.cs


示例7: Entry_HasId_RemembersId

		public void Entry_HasId_RemembersId()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				LexEntry entry = session.CreateItem();
				entry.Id = "my id";
				//_lexEntryRepository.SaveItem(entry);
				session.LiftWriter.Add(entry);
				session.LiftWriter.End();
				string result = session.StringBuilder.ToString();
				AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath("//entry[@id='my id']");
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:13,代码来源:LiftWriterTests.cs


示例8: CustomOptionRefCollectionOnExample

		public void CustomOptionRefCollectionOnExample()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				//_fieldToOptionListName.Add("flubs", "colors");
				var example = new LexExampleSentence();
				var o = example.GetOrCreateProperty<OptionRefCollection>("flubs");
				o.AddRange(new[] {"orange", "blue"});
				session.LiftWriter.Add(example);
				session.LiftWriter.End();
				string expected = CanonicalXml.ToCanonicalStringFragment(
					"<example><trait name=\"flubs\" value=\"orange\" /><trait name=\"flubs\" value=\"blue\" /></example>"
				);
				Assert.AreEqual(
					expected,
					session.StringBuilder.ToString()
				);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:19,代码来源:LiftWriterTests.cs


示例9: CustomOptionRefOnEntry

		public void CustomOptionRefOnEntry()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				//_fieldToOptionListName.Add("flub", "kindsOfFlubs");
				LexEntry entry = session.CreateItem();

				var o = entry.GetOrCreateProperty<OptionRef>("flub");
				o.Value = "orange";
				//_lexEntryRepository.SaveItem(entry);
				session.LiftWriter.Add(entry);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch(
					"entry/trait[@name='flub' and @value='orange']",
					session
				);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:18,代码来源:LiftWriterTests.cs


示例10: CustomMultiTextOnSense

		public void CustomMultiTextOnSense()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var sense = new LexSense();
				var m = sense.GetOrCreateProperty<MultiText>("flubadub");
				m["zz"] = "orange";
				session.LiftWriter.Add(sense);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("sense/field[@type='flubadub']/form[@lang='zz' and text='orange']", session);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:12,代码来源:LiftWriterTests.cs


示例11: CustomOptionRefCollectionOnEntry

		public void CustomOptionRefCollectionOnEntry()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				//_fieldToOptionListName.Add("flubs", "colors");
				LexEntry entry = session.CreateItem();

				var o = entry.GetOrCreateProperty<OptionRefCollection>("flubs");
				o.AddRange(new[] {"orange", "blue"});
				//_lexEntryRepository.SaveItem(entry);
				session.LiftWriter.Add(entry);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("entry/trait[@name='flubs' and @value='orange']", session);
				AssertHasAtLeastOneMatch("entry/trait[@name='flubs' and @value='blue']", session);
				AssertHasAtLeastOneMatch("entry[count(trait) =2]", session);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:17,代码来源:LiftWriterTests.cs


示例12: CustomMultiTextOnEntry

		public void CustomMultiTextOnEntry()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var entry = session.CreateItem();

				var m = entry.GetOrCreateProperty<MultiText>("flubadub");
				m["zz"] = "orange";
				//_lexEntryRepository.SaveItem(entry);
				session.LiftWriter.Add(entry);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("entry/field[@type='flubadub']/form[@lang='zz' and text='orange']", session);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:14,代码来源:LiftWriterTests.cs


示例13: FieldWithTraits

		public void FieldWithTraits()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var variant = new LexVariant();
				variant.SetAlternative("etr", "one");
				var fieldA = new LexField("a");
				fieldA.SetAlternative("en", "aaa");
				fieldA.Traits.Add(new LexTrait("one", "1"));
				variant.Fields.Add(fieldA);
				session.LiftWriter.AddVariant(variant);
				session.LiftWriter.End();
				AssertHasOneMatch("variant/field[@type='a']/trait[@name='one' and @value='1']", session);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:15,代码来源:LiftWriterTests.cs


示例14: VariantWith2SimpleFields

		public void VariantWith2SimpleFields()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var variant = new LexVariant();
				variant.SetAlternative("etr", "one");
				var fieldA = new LexField("a");
				fieldA.SetAlternative("en", "aaa");
				variant.Fields.Add(fieldA);
				var fieldB = new LexField("b");
				fieldB.SetAlternative("en", "bbb");
				variant.Fields.Add(fieldB);
				session.LiftWriter.AddVariant(variant);
				session.LiftWriter.End();
				AssertHasOneMatch("variant/field[@type='a']/form[@lang='en' and text = 'aaa']", session);
				AssertHasOneMatch("variant/field[@type='b']/form[@lang='en' and text = 'bbb']", session);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:18,代码来源:LiftWriterTests.cs


示例15: EmptyExampleSource_NoAttribute

		public void EmptyExampleSource_NoAttribute()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var ex = new LexExampleSentence();
				ex.GetOrCreateProperty<OptionRef>(
					LexExampleSentence.WellKnownProperties.Source
				);
				session.LiftWriter.Add(ex);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("example[not(@source)]", session);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:13,代码来源:LiftWriterTests.cs


示例16: CustomOptionRefOnSense

		public void CustomOptionRefOnSense()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				//_fieldToOptionListName.Add("flub", "kindsOfFlubs");
				var sense = new LexSense();
				var o = sense.GetOrCreateProperty<OptionRef>("flub");
				o.Value = "orange";
				session.LiftWriter.Add(sense);
				session.LiftWriter.End();
				string expected = CanonicalXml.ToCanonicalStringFragment(
					GetSenseElement(sense) + "<trait name=\"flub\" value=\"orange\" /></sense>"
				);
				Assert.AreEqual(
					expected,
					session.StringBuilder.ToString()
				);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:19,代码来源:LiftWriterTests.cs


示例17: EmptyNoteOnEntry_NoOutput

		public void EmptyNoteOnEntry_NoOutput()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				LexEntry entry = session.CreateItem();
				entry.GetOrCreateProperty<MultiText>(PalasoDataObject.WellKnownProperties.Note);
				//_lexEntryRepository.SaveItem(entry);
				session.LiftWriter.Add(entry);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("entry[not(note)]", session);
				AssertHasAtLeastOneMatch("entry[not(field)]", session);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:13,代码来源:LiftWriterTests.cs


示例18: CustomOptionRefOnSenseWithGrammi

		public void CustomOptionRefOnSenseWithGrammi()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				//_fieldToOptionListName.Add("flub", "kindsOfFlubs");
				var sense = new LexSense();
				var grammi = sense.GetOrCreateProperty<OptionRef>(
					LexSense.WellKnownProperties.PartOfSpeech
				);
				grammi.Value = "verb";

				var o = sense.GetOrCreateProperty<OptionRef>("flub");
				o.Value = "orange";
				session.LiftWriter.Add(sense);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("sense/trait[@name='flub' and @value='orange']", session);
				AssertHasAtLeastOneMatch("sense[count(trait)=1]", session);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:19,代码来源:LiftWriterTests.cs


示例19: Entry_ScaryUnicodeCharacter_SafeXmlEmitted

		public void Entry_ScaryUnicodeCharacter_SafeXmlEmitted()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				LexEntry entry = session.CreateItem();
				entry.LexicalForm["test"] = '\u001F'.ToString();
				session.LiftWriter.Add(entry);
				session.LiftWriter.End();

				var doc = new XmlDocument();
				//this next line will crash if things aren't safe
				doc.LoadXml(session.StringBuilder.ToString());
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:14,代码来源:LiftWriterTests.cs


示例20: DefinitionOnSense_OutputAsDefinition

		public void DefinitionOnSense_OutputAsDefinition()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var sense = new LexSense();
				var m = sense.GetOrCreateProperty<MultiText>(
					LexSense.WellKnownProperties.Definition
				);
				m["zz"] = "orange";
				session.LiftWriter.Add(sense);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("sense/definition/form[@lang='zz']/text[text()='orange']", session);
				AssertHasAtLeastOneMatch("sense[not(field)]", session);
			}
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:15,代码来源:LiftWriterTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Light类代码示例发布时间:2022-05-24
下一篇:
C# Lifetime类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap