However, ultimately you can't learn a technology without jumping in and making a whole bunch of stupid mistakes.
[Test]
public void Properties()
{
Patient patient = new Patient();
int intTestData = 0;
foreach (string propertyName in GetProperties(new Patient()))
{
Type patientType = patient.GetType();
PropertyInfo property = patientType.GetProperty(propertyName);
string stringTestData;
if (property.PropertyType == typeof(System.String))
{
intTestData++;
stringTestData = String.Format("Testdata{0}", intTestData);
Console.WriteLine(String.Format("Testing property {0} of type {1} with value {2}", propertyName, property.PropertyType.ToString(),stringTestData));
if (property.CanWrite == true && property.CanRead == true)
{
property.SetValue(patient, stringTestData, null);
Assert.AreEqual(stringTestData,property.GetValue(patient,null));
}
}
if (property.PropertyType == typeof(System.Int32))
{
property.SetValue(patient, intTestData, null);
Assert.AreEqual(intTestData, property.GetValue(patient, null));
}
}
}