Пример #1
0
        public void XliffWriter_Target()
        {
            Target target;
            Unit unit;
            string actualValue;

            this._document.Files.Add(new File());
            unit = new Unit();
            this._document.Files[0].Containers.Add(unit);
            unit.Resources.Add(new Segment());
            target = new Target();
            unit.Resources[0].Target = target;

            Console.WriteLine("Test with default values.");
            actualValue = this.Serialize();
            Assert.AreEqual(TestUtilities.GetFileContents(TestData.TargetWithDefaultValues), actualValue);

            Console.WriteLine("Test with empty values.");
            target.Language = String.Empty;
            actualValue = this.Serialize();
            Assert.AreEqual(TestUtilities.GetFileContents(TestData.TargetWithEmptyValues), actualValue);

            Console.WriteLine("Test with valid values.");
            target.Language = "en-us";
            target.Order = 100;
            target.Space = Preservation.Preserve;
            target.Text.Add(new CodePoint(1));
            actualValue = this.Serialize();
            Assert.AreEqual(TestUtilities.GetFileContents(TestData.TargetWithValidValues), actualValue);
        }
Пример #2
0
        /// <summary>
        /// Creates a target with every element and attribute.
        /// </summary>
        /// <param name="noteId">The Id of a note to reference.</param>
        /// <returns>The created target.</returns>
        private Target CreateTarget(string noteId)
        {
            IIdentifiable identifiable1;
            IIdentifiable identifiable2;
            Target result;

            result = new Target();
            result.Language = "de-de";
            result.Space = Preservation.Preserve;
            result.Order = 1;
            result.Text.Add(new CodePoint(24));
            identifiable1 = this.CreatePh(null);
            result.Text.Add((ResourceStringContent)identifiable1);
            result.Text.Add(this.CreatePh(identifiable1.Id));
            identifiable1 = this.CreatePc(null);
            result.Text.Add((ResourceStringContent)identifiable1);
            result.Text.Add(this.CreatePc(identifiable1.Id));

            identifiable1 = this.CreateSc(null);
            result.Text.Add((ResourceStringContent)identifiable1);
            identifiable2 = this.CreateEc(null, identifiable1.Id);
            result.Text.Add((ResourceStringContent)identifiable2);
            result.Text.Add(this.CreateEc(null, null));

            identifiable1 = this.CreateSc(identifiable1.Id);
            result.Text.Add((ResourceStringContent)identifiable1);
            result.Text.Add(this.CreateEc(identifiable2.Id, identifiable1.Id));

            result.Text.Add(new PlainText("text"));
            result.Text.Add(new CDataTag("cdata text"));
            result.Text.Add(new CommentTag("comment text"));
            result.Text.Add(new ProcessingInstructionTag("instruction", "instruction text"));
            result.Text.Add(this.CreateMrk(noteId));

            identifiable1 = this.CreateSm(noteId);
            result.Text.Add((ResourceStringContent)identifiable1);
            result.Text.Add(this.CreateEm(identifiable1.Id));

            return result;
        }