Example #1
0
        public void TestConstructor_ValidIdentifier()
        {
            string id             = "ID";
            CompressorAttribute a = new CompressorAttribute(id);

            Assert.AreEqual(id, a.Identifier);
        }
Example #2
0
        /// <summary>
        /// Scrutinizes the variable attribute and ensures it has been annotated correctly.
        /// </summary>
        /// <param name="attr">The attribute to scrutinize.</param>
        private static void _guardBadAttribute(AlgorithmPropertyAttribute attr)
        {
            if (attr.CompressorType != null)
            {
                CompressorAttribute cattr = attr.CompressorType.GetCustomAttribute(
                    typeof(CompressorAttribute)) as CompressorAttribute;
                if (cattr == null)
                {
                    throw new ArgumentException("Compressor type provided not annotated.");
                }

                if (attr.CompressorType.GetInterfaces().Contains(typeof(ICompressor)) == false)
                {
                    throw new ArgumentException("Compressor type does not implement ICompressor.");
                }
            }

            if (attr.PublicType != null)
            {
                if (attr.PublicTypeConverter == null)
                {
                    throw new ArgumentException("Faux type converter not provided.");
                }

                if (attr.PublicTypeConverter.GetInterfaces().Contains(typeof(IValueConverter)) == false)
                {
                    throw new ArgumentException("PublicTypeConverter does not implement IValueConverter.");
                }
            }
        }
Example #3
0
 public void TestConstructor_EmptyIdentifier()
 {
     CompressorAttribute a = new CompressorAttribute(string.Empty);
 }
Example #4
0
 public void TestConstructor_NullIdentifier()
 {
     CompressorAttribute a = new CompressorAttribute(null);
 }