diff --git a/CHANGELOG.md b/CHANGELOG.md index 77269b1..f0bab60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ Added support for: - `MapEach`: maps each `Result` in the sequence, preserving the failed `Result`s - `BindEach`: binds each `Result` in the sequence, preserving the failed `Result`s - `MatchEach`: matches each `Result` in the sequence - - `AggregateResult`: transforms a sequence of `Result`s into a single `Result` that contains a sequence of the successful values. If the original sequence contains any `Error` then will return a failed `Result` with an `AggregateError` containing all the errors found. + - `AggregateResults`: transforms a sequence of `Result`s into a single `Result` that contains a sequence of the successful values. If the original sequence contains any `Error` then will return a failed `Result` with an `AggregateError` containing all the errors found. ### Breaking Changes - The following extension methods on `IEnumerable>` have been removed: diff --git a/README.md b/README.md index 15f90e6..5052f78 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ The library provide a set of extension methods that enable manipulation of seque * `MapEach`: Maps each `Result` in the sequence, preserving the failed `Result`s * `BindEach`: Binds each `Result` in the sequence, preserving the failed `Result`s * `MatchEach`: Matches each `Result` in the sequence -* `AggregateResult`: Transforms a sequence of `Result`s into a single `Result` that contains a sequence of the successful values. If the original sequence contains any `Error` then will return a failed `Result` with an `AggregateError` containing all the errors found. +* `AggregateResults`: Transforms a sequence of `Result`s into a single `Result` that contains a sequence of the successful values. If the original sequence contains any `Error` then will return a failed `Result` with an `AggregateError` containing all the errors found. ## Design Goals for `Error` diff --git a/src/Monads/Result/ResultEnumerableExtensions.SelectValues.cs b/src/Monads/Result/ResultEnumerableExtensions.SelectValues.cs index 73c4707..957e201 100644 --- a/src/Monads/Result/ResultEnumerableExtensions.SelectValues.cs +++ b/src/Monads/Result/ResultEnumerableExtensions.SelectValues.cs @@ -56,6 +56,6 @@ public static IEnumerable MatchEach( /// /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Result> AggregateResult(this IEnumerable> results) + public static Result> AggregateResults(this IEnumerable> results) => new ResultCollection(results).ToResult(); } \ No newline at end of file diff --git a/test/Monads.UnitTests/ResultTests/ResultEnumerableExtensionsTests.cs b/test/Monads.UnitTests/ResultTests/ResultEnumerableExtensionsTests.cs index 482d43c..6459137 100644 --- a/test/Monads.UnitTests/ResultTests/ResultEnumerableExtensionsTests.cs +++ b/test/Monads.UnitTests/ResultTests/ResultEnumerableExtensionsTests.cs @@ -174,7 +174,7 @@ public void AggregateResult_AllSuccess_Returns_a_Success() Result.Success(new Value(5)) }; - var actual = results.AggregateResult(); + var actual = results.AggregateResults(); actual.Should().BeOfType>>(); actual.IsSuccess.Should().BeTrue(); @@ -194,7 +194,7 @@ public void AggregateResult_AllFailures_Returns_a_Failure() Result.Failure("Error 5") }; - var actual = results.AggregateResult(); + var actual = results.AggregateResults(); var expectedError = new AggregateError(results.Select(r => r.GetErrorOrThrow())); actual.Should().BeOfType>>(); @@ -215,7 +215,7 @@ public void AggregateResult_SomeFailures_Returns_a_Failure() Result.Success(new Value(5)) }; - var actual = results.AggregateResult(); + var actual = results.AggregateResults(); var expectedError = new AggregateError(results.Where(r => r.IsFailure).Select(r => r.GetErrorOrThrow())); actual.Should().BeOfType>>();