/// <summary>Write the custom failure message for this object's <see cref="CollectionEquivalentConstraint"/>.</summary> /// <param name="writer">The <see cref="MessageWriter"/> to write the failure message to.</param> public override void WriteMessageTo(MessageWriter writer) { //Write the expected/actual message first. base.WriteMessageTo(writer); if (_tallyResult.MissingItems.Count > 0) { int missingItemsCount = _tallyResult.MissingItems.Count; string missingStr = $"Missing ({missingItemsCount}): "; missingStr += MsgUtils.FormatCollection(_tallyResult.MissingItems, 0, MaxDifferingElemsToWrite); writer.WriteMessageLine(missingStr); } if (_tallyResult.ExtraItems.Count > 0) { int extraItemsCount = _tallyResult.ExtraItems.Count; string extraStr = $"Extra ({extraItemsCount}): "; extraStr += MsgUtils.FormatCollection(_tallyResult.ExtraItems, 0, MaxDifferingElemsToWrite); writer.WriteMessageLine(extraStr); } }
/// <summary>Write any additional lines (following <c>Expected:</c> and <c>But was:</c>) for a failing constraint.</summary> /// <param name="writer">The <see cref="MessageWriter"/> to write the failure message to.</param> public override void WriteAdditionalLinesTo(MessageWriter writer) { if (_tallyResult.MissingItems.Count > 0) { int missingItemsCount = _tallyResult.MissingItems.Count; string missingStr = $"Missing ({missingItemsCount}): "; missingStr += MsgUtils.FormatCollection(_tallyResult.MissingItems); writer.WriteMessageLine(missingStr); } if (_tallyResult.ExtraItems.Count > 0) { int extraItemsCount = _tallyResult.ExtraItems.Count; string extraStr = $"Extra ({extraItemsCount}): "; extraStr += MsgUtils.FormatCollection(_tallyResult.ExtraItems); writer.WriteMessageLine(extraStr); } }
/// <summary> /// Writes the text for a collection value, /// starting at a particular point, to a max length /// </summary> /// <param name="collection">The collection containing elements to write.</param> /// <param name="start">The starting point of the elements to write</param> /// <param name="max">The maximum number of elements to write</param> public override void WriteCollectionElements(IEnumerable collection, long start, int max) { Write(MsgUtils.FormatCollection(collection, start, max)); }