Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove option to skip formatting of argument values #1665

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 6 additions & 15 deletions src/FakeItEasy/OutputWriterExtensions.cs
Expand Up @@ -57,24 +57,23 @@ public static IOutputWriter Write(this IOutputWriter writer, object value)
/// </summary>
/// <param name="writer">The writer to write to.</param>
/// <param name="values">The values to write to the writer.</param>
/// <param name="skipFormatting">Specify that argument values should not be formatted.</param>
/// <returns>The writer.</returns>
internal static IOutputWriter WriteArgumentValues(this IOutputWriter writer, IEnumerable values, bool skipFormatting = false)
internal static IOutputWriter WriteArgumentValues(this IOutputWriter writer, IEnumerable values)
{
Guard.AgainstNull(writer, nameof(writer));
Guard.AgainstNull(values, nameof(values));

var list = values.AsList();
if (list.Count <= 5)
{
writer.WriteArgumentValuesImpl(list, skipFormatting);
writer.WriteArgumentValuesImpl(list);
}
else
{
writer.WriteArgumentValuesImpl(list.Take(2), skipFormatting);
writer.WriteArgumentValuesImpl(list.Take(2));
int remainingCount = list.Count - 4;
writer.Write($", … ({remainingCount} more elements) …, ");
writer.WriteArgumentValuesImpl(list.Skip(list.Count - 2), skipFormatting);
writer.WriteArgumentValuesImpl(list.Skip(list.Count - 2));
}

return writer;
Expand All @@ -85,9 +84,8 @@ internal static IOutputWriter WriteArgumentValues(this IOutputWriter writer, IEn
/// </summary>
/// <param name="writer">The writer to write to.</param>
/// <param name="values">The values to write to the writer.</param>
/// <param name="skipFormatting">Specify that argument values should not be formatted.</param>
/// <returns>The writer.</returns>
private static IOutputWriter WriteArgumentValuesImpl(this IOutputWriter writer, IEnumerable values, bool skipFormatting = false)
private static IOutputWriter WriteArgumentValuesImpl(this IOutputWriter writer, IEnumerable values)
{
bool first = true;
foreach (var value in values)
Expand All @@ -97,14 +95,7 @@ private static IOutputWriter WriteArgumentValuesImpl(this IOutputWriter writer,
writer.Write(", ");
}

if (skipFormatting)
{
writer.Write(value);
}
else
{
writer.WriteArgumentValue(value);
}
writer.WriteArgumentValue(value);

first = false;
}
Expand Down