public void XliffWriter_FullDocument() { File file; Group group1; Group group2; Ignorable ignorable; Note note; Segment segment; Skeleton skeleton; Unit unit; string actualValue; this._document.SourceLanguage = "en-us"; this._document.Space = Preservation.Default; this._document.TargetLanguage = "de-de"; this._document.Version = "version"; file = new File(); file.CanResegment = true; file.Id = "id"; file.Original = "original"; file.SourceDirectionality = ContentDirectionality.LTR; file.Space = Preservation.Preserve; file.TargetDirectionality = ContentDirectionality.RTL; file.Translate = true; this._document.Files.Add(file); group1 = new Group(); group1.CanResegment = true; group1.Id = "id"; group1.Name = "name"; group1.SourceDirectionality = ContentDirectionality.RTL; group1.Space = Preservation.Preserve; group1.TargetDirectionality = ContentDirectionality.Auto; group1.Translate = true; group1.Type = "type"; file.Containers.Add(group1); group2 = new Group(); group2.CanResegment = false; group2.Id = "id2"; group2.Name = "name2"; group2.SourceDirectionality = ContentDirectionality.LTR; group2.Space = Preservation.Default; group2.TargetDirectionality = ContentDirectionality.RTL; group2.Translate = false; group2.Type = "type2"; file.Containers.Add(group2); unit = new Unit(); unit.CanResegment = false; unit.Id = "id"; unit.Name = "name"; unit.Notes.Add(new Note("text")); unit.SourceDirectionality = ContentDirectionality.LTR; unit.Space = Preservation.Default; unit.TargetDirectionality = ContentDirectionality.Auto; unit.Translate = true; unit.Type = "type"; group2.Containers.Add(unit); unit.OriginalData = new OriginalData(); unit.OriginalData.AddData("id", "data1"); unit.OriginalData.DataElements[0].Directionality = ContentDirectionality.RTL; unit.OriginalData.DataElements[0].Space = Preservation.Preserve; unit.OriginalData.DataElements[0].Text.Add(new CodePoint(1)); unit = new Unit(); unit.CanResegment = false; unit.Id = "id2"; unit.Name = "name2"; unit.Notes.Add(new Note("text2")); unit.SourceDirectionality = ContentDirectionality.RTL; unit.Space = Preservation.Preserve; unit.TargetDirectionality = ContentDirectionality.LTR; unit.Translate = false; unit.Type = "type2"; group2.Containers.Add(unit); unit.OriginalData = new OriginalData(); unit.OriginalData.AddData("id1", "data1"); unit.OriginalData.DataElements[0].Directionality = ContentDirectionality.LTR; unit.OriginalData.DataElements[0].Space = Preservation.Preserve; unit.OriginalData.DataElements[0].Text.Add(new CodePoint(2)); unit.OriginalData.AddData("id2", "data2"); unit.OriginalData.DataElements[1].Directionality = ContentDirectionality.RTL; unit.OriginalData.DataElements[1].Space = Preservation.Preserve; unit.OriginalData.DataElements[1].Text.Add(new CodePoint(1)); ignorable = new Ignorable(); ignorable.Id = "id"; ignorable.Source = new Source("text"); ignorable.Target = new Target("text"); unit.Resources.Add(ignorable); segment = new Segment(); segment.CanResegment = true; segment.Id = "id"; segment.Source = new Source(); segment.State = TranslationState.Reviewed; segment.SubState = "substate"; segment.Target = new Target(); segment.Source.Language = "en-us"; segment.Source.Space = Preservation.Default; segment.Source.Text.Add(new CodePoint(1)); segment.Source.Text.Add(new PlainText("text")); segment.Target.Language = "en-us"; segment.Target.Order = 100; segment.Target.Space = Preservation.Default; segment.Target.Text.Add(new CodePoint(12)); segment.Target.Text.Add(new PlainText("text2")); unit.Resources.Add(segment); note = new Note(); note.AppliesTo = TranslationSubject.Source; note.Category = "category"; note.Id = "id"; note.Priority = 2; note.Text = "text"; file.Notes.Add(note); file.Notes.Add(new Note("text2")); skeleton = new Skeleton(); skeleton.HRef = "href"; skeleton.NonTranslatableText = "text"; file.Skeleton = skeleton; file = new File(); file.CanResegment = false; file.Id = "id2"; file.Notes.Add(new Note("text")); file.Original = "original2"; file.SourceDirectionality = ContentDirectionality.Auto; file.Space = Preservation.Default; file.TargetDirectionality = ContentDirectionality.LTR; file.Translate = false; this._document.Files.Add(file); skeleton = new Skeleton(); skeleton.HRef = "href"; skeleton.NonTranslatableText = "text"; file.Skeleton = skeleton; actualValue = this.Serialize(); Assert.AreEqual(TestUtilities.GetFileContents(TestData.FullDocument), actualValue); }
public void XliffWriter_Group() { File file; Group group; string actualValue; file = new File(); this._document.Files.Add(file); group = new Group(); file.Containers.Add(group); Console.WriteLine("Test with default values."); actualValue = this.Serialize(); Assert.AreEqual(TestUtilities.GetFileContents(TestData.GroupWithDefaultValues), actualValue); Console.WriteLine("Test with empty values."); group.Id = String.Empty; group.Name = String.Empty; group.Type = String.Empty; actualValue = this.Serialize(); Assert.AreEqual(TestUtilities.GetFileContents(TestData.GroupWithEmptyValues), actualValue); Console.WriteLine("Test with valid values."); group.CanResegment = false; group.Id = "id"; group.Name = "name"; group.SourceDirectionality = ContentDirectionality.Auto; group.Space = Preservation.Default; group.TargetDirectionality = ContentDirectionality.LTR; group.Translate = true; group.Type = "type"; actualValue = this.Serialize(); Assert.AreEqual(TestUtilities.GetFileContents(TestData.GroupWithValidValues), actualValue); }
/// <summary> /// Creates a group with every element and attribute. /// </summary> /// <returns>The created group.</returns> private Group CreateGroup(bool nest) { Group result; result = new Group("g" + this.GetNextId(typeof(Group))); result.Name = "group"; result.CanResegment = true; result.FormatStyle = FormatStyleValue.Anchor; result.SizeInfoReference = "sizeref"; result.SizeRestriction = "restriction"; result.SourceDirectionality = ContentDirectionality.LTR; result.Space = Preservation.Default; result.StorageRestriction = "restriction"; result.SubFormatStyle.Add("key1", "value1"); result.SubFormatStyle.Add("key2", "value2"); result.TargetDirectionality = ContentDirectionality.RTL; result.Translate = false; result.Type = "pre:type"; this.AddExtension(result); this.AddNote(result); if (nest) { result.Containers.Add(this.CreateGroup(false)); } result.Containers.Add(this.CreateUnit()); result.Changes = this.CreateChangeTrackingModule_ChangeTrack(); result.Metadata = this.CreateMetadata(); result.ProfileData = this.CreateSizeRestrictionModule_ProfileData(); result.ValidationRules = this.CreateValidationModule_Validation(); return result; }