public void TestMultipleMIAM()
        {
            MultipleTestMIA src = TestCommonUtils.CreateMultipleMIA("Multiple", Cardinality.Inline, true, false);

            TextWriter writer     = new StringWriter();
            XmlWriter  serialiser = new XmlTextWriter(writer);

            serialiser.WriteStartElement("Test");
            src.Metadata.Serialize(serialiser);
            serialiser.WriteEndElement();

            Console.WriteLine("XML: {0}", writer);

            XmlReader reader = XmlReader.Create(new StringReader(writer.ToString()));

            reader.Read(); // Test tag

            reader.Read(); // MIAM tag
            MultipleMediaItemAspectMetadata dest = MediaItemAspectMetadata.Deserialize(reader) as MultipleMediaItemAspectMetadata;

            Assert.IsNotNull(dest, "Dest");
            Assert.AreEqual(src.Metadata.AspectId, dest.AspectId, "Aspect ID");
            Assert.AreEqual(src.Metadata.AttributeSpecifications.Count, dest.AttributeSpecifications.Count, "Attribute spec count");

            AssertMultipleMIAMSpec(src.Metadata.AttributeSpecifications.Values, dest.AttributeSpecifications.Values, src.ATTR_STRING);

            Assert.IsNotNull(src.Metadata.UniqueAttributeSpecifications, "Source unique spec");
            Assert.IsNotNull(dest.UniqueAttributeSpecifications, "Source unique spec");

            Assert.AreEqual(src.Metadata.UniqueAttributeSpecifications.Count, dest.UniqueAttributeSpecifications.Count, "Attribute unique spec count");

            AssertMultipleMIAMSpec(src.Metadata.UniqueAttributeSpecifications.Values, dest.UniqueAttributeSpecifications.Values, src.ATTR_ID);
        }
Beispiel #2
0
        public static MultipleTestMIA CreateMultipleMIA(string table, Cardinality cardinality, bool createStringAttribute, bool createIntegerAttribute)
        {
            MultipleTestMIA mia = new MultipleTestMIA();

            mia.ASPECT_ID = Guid.NewGuid();

            IList <MediaItemAspectMetadata.MultipleAttributeSpecification> attributes = new List <MediaItemAspectMetadata.MultipleAttributeSpecification>();

            attributes.Add(mia.ATTR_ID = MediaItemAspectMetadata.CreateMultipleStringAttributeSpecification("ATTR_ID", 10, Cardinality.Inline, true));
            if (createStringAttribute)
            {
                attributes.Add(mia.ATTR_STRING = MediaItemAspectMetadata.CreateMultipleStringAttributeSpecification("ATTR_STRING", 10, cardinality, false));
            }
            if (createIntegerAttribute)
            {
                attributes.Add(mia.ATTR_INTEGER = MediaItemAspectMetadata.CreateMultipleAttributeSpecification("ATTR_INTEGER", typeof(Int32), cardinality, true));
            }

            mia.Metadata = new MultipleMediaItemAspectMetadata(mia.ASPECT_ID, table, attributes.ToArray(), new[] { mia.ATTR_ID });

            return(mia);
        }