private void PopulateControlFromEntity(IGenericCatWebControl correspondingControl, PropertyInfo entityProperty) { correspondingControl.SetDataSource(entityProperty.GetCustomAttributes(typeof(ReferenceMappingAttribute), false)); object value = entityProperty.GetValue(_Entity, null); //If the catalogue is in add mode, the value is numeric and null, do not populate the catalogue. In all other situations. //populate the control with the corresponding value if (!(!_EditMode && ApplicationUtils.AssertValueIsNumeric(value) && ApplicationUtils.AssertValueIsNull(value))) { if (!(correspondingControl is IndCatTextBox && entityProperty.Name == "Rank" && !_EditMode)) { correspondingControl.SetValue(value); } } }
public void AssertValueIsNumericTest() { bool result; int intTestValue = ApplicationConstants.INT_NULL_VALUE; result = ApplicationUtils.AssertValueIsNumeric(intTestValue); Assert.AreEqual(true, result); short shortTestValue = ApplicationConstants.SHORT_NULL_VALUE; result = ApplicationUtils.AssertValueIsNumeric(shortTestValue); Assert.AreEqual(true, result); decimal decimalTestValue = ApplicationConstants.DECIMAL_NULL_VALUE; result = ApplicationUtils.AssertValueIsNumeric(decimalTestValue); Assert.AreEqual(true, result); string stringTestValue = String.Empty; result = ApplicationUtils.AssertValueIsNumeric(stringTestValue); Assert.AreEqual(false, result); }