public void ParameterPropertyTest()
{
// Dynamically enumerate all univariate distributions and make
// sure the distribution contains properties for every exposed
// constructors' parameters
var baseType = typeof(IUnivariateDistribution);
var assembly = Assembly.GetAssembly(baseType);
// Get all univariate distributions in Accord.NET:
var distributions = assembly.GetTypes().Where(p =>
baseType.IsAssignableFrom(p) && !p.IsAbstract && !p.IsInterface);
var check = new HashSet<Type>();
foreach (Type type in distributions)
{
if (!typeof(IUnivariateDistribution).IsAssignableFrom(type))
continue;
foreach (var ctor in type.GetConstructors())
{
foreach (var param in ctor.GetParameters())
{
string distName = type.Name;
string paramName = param.Name;
// Search for a property with a similar name
var p = type.GetProperties().FirstOrDefault(
prop => cmp(distName, paramName, prop.Name));
bool found = p != null;
Assert.IsTrue(found);
check.Add(type);
}
}
}
var checkedTypes = check.ToArray();
Assert.IsTrue(checkedTypes.Length >= 57);
}