public void VisitFile() { ResourceData rd1 = new ResourceData("rd1", new ResourceItem("ri1", new Source("https://open.vistatec.com/ocelot"))); JliffDocument jlb = new JliffBuilder("en-US", "it-IT") .AddFile(new XlfEventArgs("f1")) .AddUnit(new XlfEventArgs("u1")) .EndSubFiles() .AddSegment(new XlfEventArgs("s1")) .EndSubUnits() .AddSource("Hello") .AddSmElement("mrk1", true) .AddSource("there") .AddEmElement("", true) .AddTarget("Buongiorno") .MoreSubUnits() .AddSegment(new XlfEventArgs("s2")) .EndSubUnits() .AddSource("Congratulations") .MoreSubUnits() .AddSegment(new XlfEventArgs("s3")) .EndSubUnits() .AddSource("Goodbye") .AddTarget("Arrivederci") .Build(); jlb.Files[0].ResourceData = rd1; TestVisitor testVisitor = new TestVisitor(); jlb.Files[0].Accept(testVisitor); (jlb.Files[0].Subfiles[0] as Unit).Accept(testVisitor); }
public void TestComplexPartSpecifiersExampleRfc3501() { const string expected = "MULTIPART/MIXED\n TEXT/PLAIN\n APPLICATION/OCTET-STREAM\n MESSAGE/RFC822\n MULTIPART/MIXED\n TEXT/PLAIN\n APPLICATION/OCTET-STREAM\n MULTIPART/MIXED\n IMAGE/GIF\n MESSAGE/RFC822\n MULTIPART/MIXED\n TEXT/PLAIN\n MULTIPART/ALTERNATIVE\n TEXT/PLAIN\n TEXT/RICHTEXT\n"; var visitor = new TestVisitor(); BodyPart body = CreateMultipart("MULTIPART", "MIXED", "", CreateText("TEXT", "PLAIN", "1"), CreateBasic("APPLICATION", "OCTET-STREAM", "2"), CreateMessage("MESSAGE", "RFC822", "3", CreateMultipart("MULTIPART", "MIXED", "3", CreateText("TEXT", "PLAIN", "3.1"), CreateBasic("APPLICATION", "OCTET-STREAM", "3.2") ) ), CreateMultipart("MULTIPART", "MIXED", "4", CreateBasic("IMAGE", "GIF", "4.1"), CreateMessage("MESSAGE", "RFC822", "4.2", CreateMultipart("MULTIPART", "MIXED", "4.2", CreateText("TEXT", "PLAIN", "4.2.1"), CreateMultipart("MULTIPART", "ALTERNATIVE", "4.2.2", CreateText("TEXT", "PLAIN", "4.2.2.1"), CreateText("TEXT", "RICHTEXT", "4.2.2.2") ) ) ) ) ); visitor.Visit(body); Assert.AreEqual(expected, visitor.ToString()); Assert.Throws <ArgumentNullException> (() => new BodyPartText().Accept(null)); Assert.Throws <ArgumentNullException> (() => new BodyPartBasic().Accept(null)); Assert.Throws <ArgumentNullException> (() => new BodyPartMessage().Accept(null)); Assert.Throws <ArgumentNullException> (() => new BodyPartMultipart().Accept(null)); var encoded = body.ToString(); Assert.Throws <ArgumentNullException> (() => BodyPart.TryParse(null, out body)); Assert.IsTrue(BodyPart.TryParse(encoded, out body)); VerifyPartSpecifier(body); }