/// <summary> /// Write the actual value for a failing constraint test to a /// MessageWriter. TypeCOnstraints override this method to write the /// name of the type. /// </summary> /// <exception cref="ArgumentNullException">if the message writer is null.</exception> /// <param name="writer">The writer on which the actual value is displayed</param> public override void WriteActualValueTo(MessageWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } writer.WriteActualValue(Actual == null ? null : Actual.GetType()); }
///<inheritdoc/> public override bool Validate() { if (Actual == null) { return(true); } ActualDisplayName = "an object of type " + Actual.GetType().GetFriendlyName(); return(false); }
/// <summary> /// Write the actual value for a failing constraint test to a /// MessageWriter. The default implementation simply writes the raw /// value of actual, leaving it to the writer to perform any formatting. /// </summary> /// <exception cref="ArgumentNullException">if the message writer is null.</exception> /// <param name="writer">The writer on which the actual value is displayed</param> public override void WriteActualValueTo(MessageWriter writer) { if (writer == null) { throw new ArgumentNullException("writer"); } if (_propertyExists) { writer.WriteActualValue(_propValue); } else { writer.WriteActualValue(Actual.GetType()); } }
public override bool Equals(object obj) { var other = obj as EntityBase; if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } if (Actual.GetType() != other.Actual.GetType()) { return(false); } if (Id == default || other.Id == default) { return(false); } return(Id.Equals(other.Id)); }
///<inheritdoc/> public override bool Validate() { if (Actual == null) { ActualDisplayName = "null"; return(false); } var actualType = Actual.GetType(); if (actualType != Expected.GetType()) { ActualDisplayName = "an object of type " + actualType.GetFriendlyName(); return(false); } if (!Expected.Equals(Actual)) { ActualDisplayName = (bool)Expected ? "false" : "true"; return(false); } return(true); }
public override int GetHashCode() { return((Actual.GetType().ToString() + Id).GetHashCode()); }