Skip to content

Commit

Permalink
Use string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
atifaziz committed Nov 4, 2022
1 parent d684bf8 commit 46f0fac
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions MoreLinq.Test/AggregateRightTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void AggregateRight(SourceKind sourceKind)
{
var enumerable = Enumerable.Range(1, 5).Select(x => x.ToString()).ToSourceKind(sourceKind);

var result = enumerable.AggregateRight((a, b) => string.Format("({0}+{1})", a, b));
var result = enumerable.AggregateRight((a, b) => $"({a}+{b})");

Assert.That(result, Is.EqualTo("(1+(2+(3+(4+5))))"));
}
Expand Down Expand Up @@ -78,7 +78,7 @@ public void AggregateRightSeedFuncIsNotInvokedOnEmptySequence()
public void AggregateRightSeed()
{
var result = Enumerable.Range(1, 4)
.AggregateRight("5", (a, b) => string.Format("({0}+{1})", a, b));
.AggregateRight("5", (a, b) => $"({a}+{b})");

Assert.That(result, Is.EqualTo("(1+(2+(3+(4+5))))"));
}
Expand All @@ -90,14 +90,14 @@ public void AggregateRightSeed()
[TestCase(true)]
public void AggregateRightResultorWithEmptySequence(object defaultValue)
{
Assert.That(new int[0].AggregateRight(defaultValue, (a, b) => b, a => a == defaultValue), Is.EqualTo(true));
Assert.That(new int[0].AggregateRight(defaultValue, (_, b) => b, a => a == defaultValue), Is.EqualTo(true));
}

[Test]
public void AggregateRightResultor()
{
var result = Enumerable.Range(1, 4)
.AggregateRight("5", (a, b) => string.Format("({0}+{1})", a, b), a => a.Length);
.AggregateRight("5", (a, b) => $"({a}+{b})", a => a.Length);

Assert.That(result, Is.EqualTo("(1+(2+(3+(4+5))))".Length));
}
Expand Down
4 changes: 2 additions & 2 deletions MoreLinq.Test/ScanRightTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void ScanRight(SourceKind sourceKind)
var result = Enumerable.Range(1, 5)
.Select(x => x.ToString())
.ToSourceKind(sourceKind)
.ScanRight((a, b) => string.Format("({0}+{1})", a, b));
.ScanRight((a, b) => $"({a}+{b})");

var expectations = new[] { "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5" };

Expand Down Expand Up @@ -101,7 +101,7 @@ public void ScanRightSeedFuncIsNotInvokedOnEmptySequence()
public void ScanRightSeed()
{
var result = Enumerable.Range(1, 4)
.ScanRight("5", (a, b) => string.Format("({0}+{1})", a, b));
.ScanRight("5", (a, b) => $"({a}+{b})");

var expectations = new[] { "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5" };

Expand Down
6 changes: 3 additions & 3 deletions MoreLinq/AggregateRight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static partial class MoreEnumerable
/// <returns>The final accumulator value.</returns>
/// <example>
/// <code><![CDATA[
/// string result = Enumerable.Range(1, 5).Select(i => i.ToString()).AggregateRight((a, b) => string.Format("({0}/{1})", a, b));
/// string result = Enumerable.Range(1, 5).Select(i => i.ToString()).AggregateRight((a, b) => $"({a}/{b})");
/// ]]></code>
/// The <c>result</c> variable will contain <c>"(1/(2/(3/(4/5))))"</c>.
/// </example>
Expand Down Expand Up @@ -70,7 +70,7 @@ public static TSource AggregateRight<TSource>(this IEnumerable<TSource> source,
/// <example>
/// <code><![CDATA[
/// var numbers = Enumerable.Range(1, 5);
/// string result = numbers.AggregateRight("6", (a, b) => string.Format("({0}/{1})", a, b));
/// string result = numbers.AggregateRight("6", (a, b) => $"({a}/{b})");
/// ]]></code>
/// The <c>result</c> variable will contain <c>"(1/(2/(3/(4/(5/6)))))"</c>.
/// </example>
Expand Down Expand Up @@ -106,7 +106,7 @@ public static TAccumulate AggregateRight<TSource, TAccumulate>(this IEnumerable<
/// <example>
/// <code><![CDATA[
/// var numbers = Enumerable.Range(1, 5);
/// int result = numbers.AggregateRight("6", (a, b) => string.Format("({0}/{1})", a, b), str => str.Length);
/// int result = numbers.AggregateRight("6", (a, b) => $"({a}/{b})", str => str.Length);
/// ]]></code>
/// The <c>result</c> variable will contain <c>21</c>.
/// </example>
Expand Down
8 changes: 4 additions & 4 deletions MoreLinq/Extensions.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public static partial class AggregateRightExtension
/// <returns>The final accumulator value.</returns>
/// <example>
/// <code><![CDATA[
/// string result = Enumerable.Range(1, 5).Select(i => i.ToString()).AggregateRight((a, b) => string.Format("({0}/{1})", a, b));
/// string result = Enumerable.Range(1, 5).Select(i => i.ToString()).AggregateRight((a, b) => $"({a}/{b})");
/// ]]></code>
/// The <c>result</c> variable will contain <c>"(1/(2/(3/(4/5))))"</c>.
/// </example>
Expand All @@ -386,7 +386,7 @@ public static TSource AggregateRight<TSource>(this IEnumerable<TSource> source,
/// <example>
/// <code><![CDATA[
/// var numbers = Enumerable.Range(1, 5);
/// string result = numbers.AggregateRight("6", (a, b) => string.Format("({0}/{1})", a, b));
/// string result = numbers.AggregateRight("6", (a, b) => $"({a}/{b})");
/// ]]></code>
/// The <c>result</c> variable will contain <c>"(1/(2/(3/(4/(5/6)))))"</c>.
/// </example>
Expand Down Expand Up @@ -415,7 +415,7 @@ public static TAccumulate AggregateRight<TSource, TAccumulate>(this IEnumerable<
/// <example>
/// <code><![CDATA[
/// var numbers = Enumerable.Range(1, 5);
/// int result = numbers.AggregateRight("6", (a, b) => string.Format("({0}/{1})", a, b), str => str.Length);
/// int result = numbers.AggregateRight("6", (a, b) => $"({a}/{b})", str => str.Length);
/// ]]></code>
/// The <c>result</c> variable will contain <c>21</c>.
/// </example>
Expand Down Expand Up @@ -5022,7 +5022,7 @@ public static IEnumerable<TSource> ScanRight<TSource>(this IEnumerable<TSource>
/// <returns>The scanned sequence.</returns>
/// <example>
/// <code><![CDATA[
/// var result = Enumerable.Range(1, 4).ScanRight("5", (a, b) => string.Format("({0}/{1})", a, b));
/// var result = Enumerable.Range(1, 4).ScanRight("5", (a, b) => $"({a}+{b})");
/// ]]></code>
/// The <c>result</c> variable will contain <c>[ "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5" ]</c>.
/// </example>
Expand Down
2 changes: 1 addition & 1 deletion MoreLinq/ScanRight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static IEnumerable<TSource> ScanRight<TSource>(this IEnumerable<TSource>
/// <returns>The scanned sequence.</returns>
/// <example>
/// <code><![CDATA[
/// var result = Enumerable.Range(1, 4).ScanRight("5", (a, b) => string.Format("({0}/{1})", a, b));
/// var result = Enumerable.Range(1, 4).ScanRight("5", (a, b) => $"({a}+{b})");
/// ]]></code>
/// The <c>result</c> variable will contain <c>[ "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5" ]</c>.
/// </example>
Expand Down

0 comments on commit 46f0fac

Please sign in to comment.