Skip to content

Commit

Permalink
Merge pull request #105 from J-Tech-Japan/90-match-should-be-able-to-…
Browse files Browse the repository at this point in the history
…return-null

Update MatchSpec.cs
  • Loading branch information
tomohisa authored Jul 26, 2024
2 parents 06cdfa1 + 508234b commit 76dbe64
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ResultBoxes/ResultBoxes.Test/MatchSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,17 @@ public async Task MatchTest4()
Assert.Equal("err 2", result);
}

[Fact]
public async Task MatchCanReturnNullable()
{
var sut = await ResultBox.FromValue(1).ToTask().Match(value => (int?)value, exception => null);
Assert.Equal(1, sut);
}
[Fact]
public async Task MatchCanReturnNullable2()
{
var sut = await ResultBox.FromException<int>(new ApplicationException("test")).ToTask().Match(value => (int?)value, exception => null);
Assert.Null(sut);
}

}

0 comments on commit 76dbe64

Please sign in to comment.