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


C# LiftExportAsFragmentTestSession类代码示例

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


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


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