internal void EnsureConvertToStringAndBack(object seedValue) { if (_property.PropertyType.IsPrimitive || _property.PropertyType.IsEnum) { return; } GenerateValue(seedValue); var deserializedValue = ConvertFromString(); var actualEnumerable = ActualValue as IEnumerable; var deserializedEnumerable = deserializedValue as IEnumerable; if (actualEnumerable != null && deserializedEnumerable != null && SequenceEqual(actualEnumerable, deserializedEnumerable)) { return; } if (!ActualValue.Equals(deserializedValue)) // TODO check if ActualValue is IEquatable<T> { throw new NotSupportedException( string.Format( "{0} TypeConverter could not perform a successful roundtrip conversion of {1} {2} for {3}. " + "The failure to validate a successful roundtrip conversion could also be due to the fact that {1} does not implement IEquatable<T>.", _converter.GetType().Name, _property.PropertyType.Name, _property.Name, ActualValue)); } }
/// <summary> /// Returns true if Metric instances are equal /// </summary> /// <param name="other">Instance of Metric to be compared</param> /// <returns>Boolean</returns> public bool Equals(Metric other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( Severity == other.Severity || Severity.Equals(other.Severity) ) && ( Passed == other.Passed || Passed.Equals(other.Passed) ) && ( Override == other.Override || Override.Equals(other.Override) ) && ( ActualValue == other.ActualValue || ActualValue != null && ActualValue.Equals(other.ActualValue) ) && ( ExpectedValue == other.ExpectedValue || ExpectedValue != null && ExpectedValue.Equals(other.ExpectedValue) ) && ( Comparator == other.Comparator || Comparator.Equals(other.Comparator) ) && ( Kpi == other.Kpi || Kpi != null && Kpi.Equals(other.Kpi) )); }