public void SchemaEntityAttribute_Ctor()
        {
            SchemaEntityAttribute instance;

            //
            // Test with null name.
            //

            try
            {
                instance = new SchemaEntityAttribute(null, Requirement.Optional);
                Assert.Fail("Expected ArgumentNullException to be thrown.");
            }
            catch (ArgumentNullException)
            {
            }

            //
            // Test with empty name.
            //

            try
            {
                instance = new SchemaEntityAttribute(String.Empty, Requirement.Optional);
                Assert.Fail("Expected ArgumentNullException to be thrown.");
            }
            catch (ArgumentNullException)
            {
            }

            //
            // Test with whitespace name.
            //

            try
            {
                instance = new SchemaEntityAttribute("\t\n ", Requirement.Optional);
                Assert.Fail("Expected ArgumentNullException to be thrown.");
            }
            catch (ArgumentNullException)
            {
            }

            //
            // Test with string.
            //

            instance = new SchemaEntityAttribute("name", Requirement.Required);
            Assert.AreEqual(new XmlNameInfo(null, null, "name"), instance.Name, "Name was not set properly.");
            Assert.AreEqual(Requirement.Required, instance.Requirement, "Requirement was not set properly.");
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SchemaAttributes"/> class.
 /// </summary>
 /// <param name="name">The name of the property that contains these attributes.</param>
 /// <param name="converter">The converter that defines how to convert from .NET to XLIFF.</param>
 /// <param name="defaultValue">The default .NET value of the property.</param>
 /// <param name="hasValueIndicator">The indicator that defines how to determine if the value has data.</param>
 /// <param name="schema">Defines how to map the property to XLIFF.</param>
 /// <param name="inheritanceList">A list that defines how to inherit the value from ancestors.</param>
 /// <param name="outputDependencies">A list of property names that, when written, must be accompanied by the
 /// property to which this attribute is applied.</param>
 public SchemaAttributes(
     string name,
     ConverterAttribute converter,
     DefaultValueAttribute defaultValue,
     HasValueIndicatorAttribute hasValueIndicator,
     SchemaEntityAttribute schema,
     IEnumerable<InheritValueAttribute> inheritanceList,
     IEnumerable<ExplicitOutputDependencyAttribute> outputDependencies)
 {
     this.Converter = converter;
     this.DefaultValue = defaultValue;
     this.ExplicitOutputDependencies = new List<ExplicitOutputDependencyAttribute>(outputDependencies);
     this.HasValueIndicator = hasValueIndicator;
     this.InheritanceList = new List<InheritValueAttribute>(inheritanceList);
     this.Name = name;
     this.Schema = schema;
 }