public void ResourceDataDefaultValue_ResourceItemTarget()
        {
            ResourceItemTarget resource;

            resource = new ResourceItemTarget();
            Assert.IsNull(resource.HRef, "HRef is incorrect.");
            Assert.IsNull(resource.Language, "Language is incorrect.");
        }
        public void StandardValidator_ResourceData_ResourceItemTarget()
        {
            IExtensible extensible;
            ResourceData data;
            ResourceItem item;
            ResourceItemTarget target;

            target = new ResourceItemTarget();
            target.HRef = "href";

            extensible = target;

            item = new ResourceItem();
            item.Context = true;
            item.Id = "itemid";
            item.MimeType = "mime";
            item.Target = target;
            data = new ResourceData();
            data.ResourceItems.Add(item);

            this.DeserializeDocument();
            this._document.Files[0].ResourceData = data;

            Console.WriteLine("Test with null href and empty source.");
            target.HRef = null;
            this.VerifyValidationException(ValidationError.ResourceItemReferenceBaseHRefAndSubject);

            Console.WriteLine("Test with non-null href and non-empty source.");
            extensible.Extensions.Add(new GenericExtension("ext"));
            extensible.Extensions[0].AddChild(new ElementInfo(new XmlNameInfo("name"), new GenericElement()));
            target.HRef = "href";
            this.VerifyValidationException(ValidationError.ResourceItemReferenceBaseHRefAndSubject);
            extensible.Extensions.Clear();

            Console.WriteLine("Test with invalid language.");
            target.Language = "--";
            this.VerifyValidationException(ValidationError.ResourceItemTargetLangInvalid);

            Console.WriteLine("Test with language not matching document target language.");
            target.Language = "fr-zh";
            this.VerifyValidationException(ValidationError.ResourceItemTargetLangMismatch);
        }
        public void StandardValidator_ResourceData_ResourceData()
        {
            Reference reference;
            ResourceData data;
            ResourceItem item;
            ResourceItemRef itemRef;
            ResourceItemSource source;
            ResourceItemTarget target;

            item = new ResourceItem();
            data = new ResourceData();

            this.DeserializeDocument();
            this._document.Files[0].ResourceData = data;

            Console.WriteLine("Test with no items or item references.");
            this.VerifyValidationException(ValidationError.ResourceDataMissingItems);

            reference = new Reference();
            reference.HRef = "href";

            source = new ResourceItemSource();
            source.HRef = "href";

            target = new ResourceItemTarget();
            target.HRef = "href";

            itemRef = new ResourceItemRef();
            itemRef.Reference = item.Id;
            data.ResourceItemReferences.Add(itemRef);

            item.Context = true;
            item.Id = null;
            item.MimeType = "mime";
            item.References.Add(reference);
            item.Source = source;
            item.Target = target;
            data.ResourceItems.Add(item);

            Console.WriteLine("Test with valid data.");
            StandardValidatorTests._validator.Validate(this._document);
        }
        public void XliffWriter_ResourceData()
        {
            Reference reference;
            ResourceData data;
            ResourceItemRef itemRef;
            ResourceItem item;
            ResourceItemSource source;
            ResourceItemTarget target;
            string actualValue;

            data = new ResourceData();

            itemRef = new ResourceItemRef();
            itemRef.Id = "rif1";
            itemRef.Reference = "ri1";
            data.ResourceItemReferences.Add(itemRef);

            item = new ResourceItem();
            item.Context = true;
            item.Id = "ri1";
            item.MimeType = "mime";
            data.ResourceItems.Add(item);

            reference = new Reference();
            reference.HRef = "resource";
            reference.Language = "de-de";
            item.References.Add(reference);

            source = new ResourceItemSource();
            source.HRef = "resource";
            source.Language = "de-de";
            item.Source = source;

            target = new ResourceItemTarget();
            target.HRef = "resource";
            target.Language = "de-de";
            item.Target = target;

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

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

            result = new ResourceItemTarget();
            result.HRef = "resource";
            result.Language = "de-de";

            return result;
        }
 public void TestInitialize()
 {
     this.element = new ResourceItemTarget();
     this.provider = this.element;
 }