本文整理汇总了C#中LiftExportAsFragmentTestSession.OutputString方法的典型用法代码示例。如果您正苦于以下问题:C# LiftExportAsFragmentTestSession.OutputString方法的具体用法?C# LiftExportAsFragmentTestSession.OutputString怎么用?C# LiftExportAsFragmentTestSession.OutputString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LiftExportAsFragmentTestSession
的用法示例。
在下文中一共展示了LiftExportAsFragmentTestSession.OutputString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Entry_EntryHasIdWithInvalidXMLCharacters_CharactersEscaped
public void Entry_EntryHasIdWithInvalidXMLCharacters_CharactersEscaped()
{
const string expected = "id=\"<>&"'\"";
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));
}
}
示例2: 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);
}
}
示例3: BlankExample
public void BlankExample()
{
using (var session = new LiftExportAsFragmentTestSession())
{
session.LiftWriter.Add(new LexExampleSentence());
AssertEqualsCanonicalString("<example />", session.OutputString());
}
}
示例4: BlankSense
public void BlankSense()
{
using (var session = new LiftExportAsFragmentTestSession())
{
var sense = new LexSense();
session.LiftWriter.Add(sense);
AssertEqualsCanonicalString(
String.Format("<sense id=\"{0}\" />", sense.GetOrCreateId()),
session.OutputString()
);
}
}
示例5: Add_MultiTextWithMalFormedXML_IsExportedText
public void Add_MultiTextWithMalFormedXML_IsExportedText()
{
const string expected =
"<form\r\n\tlang=\"de\">\r\n\t<text>This <span href=\"reference\">is not well formed<span> XML!</text>\r\n</form>";
using (var session = new LiftExportAsFragmentTestSession())
{
var multiText = new MultiText();
multiText.SetAlternative("de", "This <span href=\"reference\">is not well formed<span> XML!");
session.LiftWriter.AddMultitextForms(null, multiText);
session.LiftWriter.End();
Assert.AreEqual(expected, session.OutputString());
}
}
示例6: Add_TextWithSpanAndMeaningfulWhiteSpace_FormattingAndWhitespaceIsUntouched
public void Add_TextWithSpanAndMeaningfulWhiteSpace_FormattingAndWhitespaceIsUntouched()
{
const string formattedText = "\rThis's <span href=\"reference\">\n is a\t\t\n\r\t span</span> with annoying whitespace!\r\n";
const string expected = "<form\r\n\tlang=\"de\">\r\n\t<text>" + formattedText + "</text>\r\n</form>";
using (var session = new LiftExportAsFragmentTestSession())
{
var multiText = new MultiText();
multiText.SetAlternative("de", formattedText);
session.LiftWriter.AddMultitextForms(null, multiText);
session.LiftWriter.End();
Assert.AreEqual(expected, session.OutputString());
}
}
示例7: Add_MalformedXmlWithWithScaryUnicodeChar_IsExportedAsText
public void Add_MalformedXmlWithWithScaryUnicodeChar_IsExportedAsText()
{
const string expected = "<form\r\n\tlang=\"de\">\r\n\t<text>This <span href=\"reference\">is not well  formed<span> XML!</text>\r\n</form>";
// 1F is the character for "Segment Separator" and you can insert it by right-clicking in windows
using (var session = new LiftExportAsFragmentTestSession())
{
var multiText = new MultiText();
multiText.SetAlternative("de", "This <span href=\"reference\">is not well \u001F formed<span> XML!");
session.LiftWriter.AddMultitextForms(null, multiText);
session.LiftWriter.End();
Assert.AreEqual(expected, session.OutputString());
}
}
示例8: AttributesWithProblematicCharacters
public void AttributesWithProblematicCharacters()
{
const string expected = "lang=\"x"y\">";
using (var session = new LiftExportAsFragmentTestSession())
{
var sense = new LexSense();
sense.Gloss["x\"y"] = "test";
session.LiftWriter.Add(sense);
session.LiftWriter.End();
string result = session.OutputString();
Assert.IsTrue(result.Contains(expected));
}
}
示例9: Add_MultiTextWithWellFormedXMLAndScaryCharacter_IsExportedAsXML
public void Add_MultiTextWithWellFormedXMLAndScaryCharacter_IsExportedAsXML()
{
const string expected =
"<form\r\n\tlang=\"de\">\r\n\t<text>This <span href=\"reference\">is well  formed</span> XML!</text>\r\n</form>";
using (var session = new LiftExportAsFragmentTestSession())
{
var multiText = new MultiText();
multiText.SetAlternative("de", "This <span href=\"reference\">is well \u001F formed</span> XML!");
session.LiftWriter.AddMultitextForms(null, multiText);
session.LiftWriter.End();
Assert.AreEqual(expected, session.OutputString());
}
}
示例10: Add_MultiTextWithScaryUnicodeChar_IsExported
public void Add_MultiTextWithScaryUnicodeChar_IsExported()
{
const string expected =
"<form\r\n\tlang=\"de\">\r\n\t<text>This has a segment separator character at the end</text>\r\n</form>";
// 1F is the character for "Segment Separator" and you can insert it by right-clicking in windows
using (var session = new LiftExportAsFragmentTestSession())
{
var multiText = new MultiText();
multiText.SetAlternative("de", "This has a segment separator character at the end\u001F");
session.LiftWriter.AddMultitextForms(null, multiText);
session.LiftWriter.End();
Assert.AreEqual(expected, session.OutputString());
}
}
示例11: AddRelationTarget_SenseWithSynonymRelations
public void AddRelationTarget_SenseWithSynonymRelations()
{
using (var session = new LiftExportAsFragmentTestSession())
{
var sense = new LexSense();
sense.AddRelationTarget("synonym", "one");
sense.AddRelationTarget("synonym", "two");
sense.AddRelationTarget("antonym", "bee");
session.LiftWriter.Add(sense);
string result = session.OutputString();
AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath(
"/sense/relation[@type='synonym' and @ref='one']"
);
AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath(
"/sense/relation[@type='synonym' and @ref='two']"
);
AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath(
"/sense/relation[@type='antonym' and @ref='bee']"
);
}
}
示例12: SenseWithSynonymRelations
public void SenseWithSynonymRelations()
{
using (var session = new LiftExportAsFragmentTestSession())
{
var sense = new LexSense();
var synonymRelationType = new LexRelationType(
"synonym",
LexRelationType.Multiplicities.Many,
LexRelationType.TargetTypes.Sense
);
var antonymRelationType = new LexRelationType(
"antonym",
LexRelationType.Multiplicities.Many,
LexRelationType.TargetTypes.Sense
);
var relations = new LexRelationCollection();
sense.Properties.Add(new KeyValuePair<string, IPalasoDataObjectProperty>("relations", relations));
relations.Relations.Add(new LexRelation(synonymRelationType.ID, "one", sense));
relations.Relations.Add(new LexRelation(synonymRelationType.ID, "two", sense));
relations.Relations.Add(new LexRelation(antonymRelationType.ID, "bee", sense));
session.LiftWriter.Add(sense);
string result = session.OutputString();
AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath(
"/sense/relation[@type='synonym' and @ref='one']"
);
AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath(
"/sense/relation[@type='synonym' and @ref='two']"
);
AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath(
"/sense/relation[@type='antonym' and @ref='bee']"
);
}
}
示例13: SenseWithExample
public void SenseWithExample()
{
using (var session = new LiftExportAsFragmentTestSession())
{
var sense = new LexSense();
var example = new LexExampleSentence();
example.Sentence["red"] = "red sunset tonight";
sense.ExampleSentences.Add(example);
session.LiftWriter.Add(sense);
string result = session.OutputString();
AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath(
"/sense/example/form[@lang='red']/text[text()='red sunset tonight']"
);
}
}
示例14: MultiText
public void MultiText()
{
using (var session = new LiftExportAsFragmentTestSession())
{
var text = new MultiText();
text["blue"] = "ocean";
text["red"] = "sunset";
session.LiftWriter.AddMultitextForms(null, text);
AssertEqualsCanonicalString(
"<form lang=\"blue\"><text>ocean</text></form><form lang=\"red\"><text>sunset</text></form>",
session.OutputString()
);
}
}
示例15: GlossWithProblematicCharacters
public void GlossWithProblematicCharacters()
{
const string expected = "<text>LessThan<GreaterThan>Ampersan&</text>";
using (var session = new LiftExportAsFragmentTestSession())
{
var sense = new LexSense();
sense.Gloss["blue"] = "LessThan<GreaterThan>Ampersan&";
session.LiftWriter.Add(sense);
string result = session.OutputString();
Assert.IsTrue(result.Contains(expected));
}
}