/// <summary> /// The callback which is called when the Changed event occurs. The method also verifies the new value has been set precisely /// </summary> /// <param name="arg"></param> /// <returns></returns> public override object OnChanged(object arg) { object value = Value; Drt.AssertEqual(_newValue, value, string.Format("Changed Event of the property ({0}) failed!", PropertyName)); return(null); }
/// <summary> /// A Constructor /// </summary> /// <param name="drt">An instance of the DrtBase</param> /// <param name="instance">An instance of the tested object like InkCanvas</param> /// <param name="propertyName">The name of the tested property like EditingMode</param> /// <param name="callback">An instance of the IEventsForwading interface. If not null, the Changed/Changing Events will be forward to the test unit's handler.</param> protected PropertyTestUnit(DrtBase drt, object instance, string propertyName, IEventsForwading callback) : base(drt) { _callback = callback; _instance = instance; _propertyInfo = _instance.GetType().GetProperty(propertyName); _propertyName = propertyName; Drt.Assert(_propertyInfo != null, string.Format("The {0} type doesn't have the property - {1}.", _instance.GetType(), propertyName)); }
public override void OnVerify() { object value = Value; if (_callback == null) { Drt.AssertEqual(_defaultValue, value, string.Format("The default value of the property ({0}) failed!", PropertyName)); } else { _callback(Drt, value, PropertyName); } }
/// <summary> /// A method which verify the value of the property /// </summary> public override void OnVerify() { if (!_isInvalidValue) { object value = Value; Drt.AssertEqual(_changingCancelling ? _oldValue : _newValue, value, string.Format("Set/Get the property ({0}) failed!", PropertyName)); } else { Drt.AssertEqual(true, _isExceptionCaught, string.Format("Invalid value test of the property ({0}) failed!", PropertyName)); } base.OnVerify(); }