public void TestConstructor_ValidIdentifier() { string id = "ID"; CompressorAttribute a = new CompressorAttribute(id); Assert.AreEqual(id, a.Identifier); }
/// <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."); } } }
public void TestConstructor_EmptyIdentifier() { CompressorAttribute a = new CompressorAttribute(string.Empty); }
public void TestConstructor_NullIdentifier() { CompressorAttribute a = new CompressorAttribute(null); }