public void ChangeTrackingDefaultValue_ChangeTrack()
        {
            ChangeTrack change;

            change = new ChangeTrack();
            Assert.AreEqual(0, change.Revisions.Count, "Revisions count is incorrect.");
        }
 public void TestInitialize()
 {
     this.element = new ChangeTrack();
     this.provider = this.element;
 }
        public void StandardValidator_ChangeTrack_ChangeTrack()
        {
            ChangeTrack change;
            Item item;
            Revision revision;
            RevisionsContainer container;

            change = new ChangeTrack();

            Console.WriteLine("Test that ChangeTrack has at least on RevisionsContainer.");
            this.DeserializeDocument();
            this._document.Files[0].Changes = change;
            this.VerifyValidationException(ValidationError.ChangeTrackMissingRevisions);

            Console.WriteLine("Test with a valid change track.");
            item = new Item();
            item.Property = "property";
            revision = new Revision();
            revision.Items.Add(item);
            container = new RevisionsContainer();
            container.AppliesTo = "appliesTo";
            container.Revisions.Add(revision);
            change.Revisions.Add(container);
            StandardValidatorTests._validator.Validate(this._document);
        }
        public void StandardValidator_ChangeTrack_RevisionsContainer()
        {
            ChangeTrack change;
            Item item;
            Revision revision;
            RevisionsContainer container;

            item = new Item();
            item.Property = "property";
            revision = new Revision();
            revision.Items.Add(item);
            container = new RevisionsContainer();
            change = new ChangeTrack();
            change.Revisions.Add(container);

            this.DeserializeDocument();
            this._document.Files[0].Changes = change;

            Console.WriteLine("Test with no revisions.");
            container.AppliesTo = "appliesTo";
            container.Reference = "reference";
            container.CurrentVersion = "version";
            this.VerifyValidationException(ValidationError.RevisionsContainerMissingRevisions);
            container.Revisions.Add(revision);

            Console.WriteLine("Test with invalid appliesTo.");
            container.AppliesTo = "!!@";
            this.VerifyValidationException(ValidationError.RevisionsContainerAppliesToNotNMToken);
            container.AppliesTo = "appliesTo";

            Console.WriteLine("Test with invalid reference.");
            container.Reference = "!!@";
            this.VerifyValidationException(ValidationError.RevisionsContainerReferenceNotNMToken);
            container.Reference = "reference";

            Console.WriteLine("Test with invalid currentVersion.");
            container.CurrentVersion = "!!@";
            this.VerifyValidationException(ValidationError.RevisionsContainerCurrentVersionNotNMToken);
            container.CurrentVersion = "version";

            Console.WriteLine("Test with valid data.");
            StandardValidatorTests._validator.Validate(this._document);
        }
        public void StandardValidator_ChangeTrack_Item()
        {
            ChangeTrack change;
            Item item;
            Revision revision;
            RevisionsContainer container;

            item = new Item();
            revision = new Revision();
            revision.Items.Add(item);
            container = new RevisionsContainer();
            container.AppliesTo = "appliesTo";
            container.Revisions.Add(revision);
            change = new ChangeTrack();
            change.Revisions.Add(container);

            this.DeserializeDocument();
            this._document.Files[0].Changes = change;

            Console.WriteLine("Test with null property.");
            item.Property = null;
            this.VerifyValidationException(ValidationError.ItemPropertyNull);

            Console.WriteLine("Test with empty property.");
            item.Property = null;
            this.VerifyValidationException(ValidationError.ItemPropertyNull);

            Console.WriteLine("Test with whitespace only property.");
            item.Property = "   ";
            this.VerifyValidationException(ValidationError.ItemPropertyNull);

            Console.WriteLine("Test with non-empty property.");
            item.Property = "property";
            StandardValidatorTests._validator.Validate(this._document);
        }
        public void XliffWriter_ChangeTrack()
        {
            ChangeTrack change;
            Item item;
            RevisionsContainer container;
            Revision revision;
            string actualValue;

            change = new ChangeTrack();

            container = new RevisionsContainer();
            container.AppliesTo = "source";
            container.Reference = "1";
            container.CurrentVersion = "ver1";
            change.Revisions.Add(container);

            revision = new Revision();
            revision.Author = "author";
            revision.ChangeDate = new DateTime(2015, 1, 2, 3, 4, 5);
            revision.Version = "ver1";
            container.Revisions.Add(revision);

            item = new Item();
            item.Property = "content";
            item.Text = "text";
            revision.Items.Add(item);

            this._document.Files.Add(new File("f1"));
            this._document.Files[0].Changes = change;

            actualValue = this.Serialize();
            Assert.AreEqual(TestUtilities.GetFileContents(TestData.FileWithChangeTrack), actualValue);
        }
        /// <summary>
        /// Creates a <see cref="ChangeTrack"/> with every element and attribute.
        /// </summary>
        /// <returns>The created <see cref="ChangeTrack"/>.</returns>
        private ChangeTrack CreateChangeTrackingModule_ChangeTrack()
        {
            ChangeTrack result;

            result = new ChangeTrack();
            result.Revisions.Add(this.CreateChangeTrackingModule_RevisionsContainer());

            return result;
        }