Skip to content

Commit

Permalink
Fixed fluent methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiryuumaru committed Feb 15, 2024
1 parent 69b05af commit 3117e04
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions TransactionHelpers.UnitTest/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void TypedResultTest()
Assert.True(result1.IsSuccess);
Assert.False(result1.IsError);
Assert.Null(result1.Error);
Assert.Throws<EmptyResultException>(result1.ThrowIfErrorOrHasNoResult);
Assert.Throws<EmptyResultException>(result1.ThrowIfErrorOrHasNoValue);

result1
.WithResult(result1)
Expand Down Expand Up @@ -69,7 +69,7 @@ public void CascadeTypedResultTest()
Assert.True(result1.IsSuccess);
Assert.False(result1.IsError);
Assert.Null(result1.Error);
Assert.Throws<EmptyResultException>(result1.ThrowIfErrorOrHasNoResult);
Assert.Throws<EmptyResultException>(result1.ThrowIfErrorOrHasNoValue);

result1
.WithResult(result1)
Expand Down
4 changes: 2 additions & 2 deletions TransactionHelpers/Interface/IResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public interface IResult<TValue> : IResult
bool HasNoValue { get; }

/// <summary>
/// Throws if the result has any _error or has no result.
/// Throws if the result has any _error or has no value.
/// </summary>
/// <exception cref="EmptyResultException">the <see cref="IResult{TValue}.Value"/> has no value.</exception>
[MemberNotNull(nameof(Value))]
void ThrowIfErrorOrHasNoResult();
void ThrowIfErrorOrHasNoValue();
}
13 changes: 12 additions & 1 deletion TransactionHelpers/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public class Result<TValue> : Result, IResult<TValue>

/// <inheritdoc/>
[MemberNotNull(nameof(Value))]
public virtual void ThrowIfErrorOrHasNoResult()
public virtual void ThrowIfErrorOrHasNoValue()
{
if (IsError)
{
Expand Down Expand Up @@ -129,4 +129,15 @@ public virtual void ThrowIfErrorOrHasNoResult()
{
return new Result<TValue>().WithError(exception);
}

/// <summary>
/// Implicit operator for <see cref="Result{TValue}"/> to <typeparamref name="TValue"/> conversion.
/// </summary>
/// <param name="result">
/// The <see cref="Result{TValue}"/> to convert.
/// </param>
public static implicit operator TValue?(Result<TValue> result)
{
return result.Value;
}
}
2 changes: 1 addition & 1 deletion TransactionHelpers/version.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
2.0.8
2.0.9
* Fixed fluent methods

0 comments on commit 3117e04

Please sign in to comment.