Skip to content

Commit

Permalink
Merge pull request #99 from J-Tech-Japan/95-veryfy-might-take-resultb…
Browse files Browse the repository at this point in the history
…oxexceptionornone

Verify can take ResultBox<ExceptionOrNone> as well
  • Loading branch information
tomohisa authored Jul 26, 2024
2 parents ed3d8fd + 8598083 commit 1822b8a
Show file tree
Hide file tree
Showing 2 changed files with 376 additions and 1 deletion.
71 changes: 71 additions & 0 deletions src/ResultBoxes/ResultBoxes.Test/VerifySpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,75 @@ public async Task VerifyWithTask4()
.Verify(v => Task.FromResult(v == 1 ? ExceptionOrNone.None : new ApplicationException("test error")));
Assert.False(sut.IsSuccess);
}

[Fact]
public async Task VerifyWithResultBox1()
{
var sut = await ResultBox.FromValue(1)
.Verify(v => ResultBox.FromValue(Task.FromResult(v == 1 ? ExceptionOrNone.None : new ApplicationException("test error"))));
Assert.True(sut.IsSuccess);
}
[Fact]
public async Task VerifyWithResultBox2()
{
var sut = await ResultBox.FromValue(1)
.Verify(v => ResultBox.FromValue(v == 1 ? ExceptionOrNone.None : new ApplicationException("test error"))).ToTask();
Assert.True(sut.IsSuccess);
}
[Fact]
public async Task VerifyWithResultBox3()
{
var sut = await ResultBox.FromValue(2)
.Verify(v => ResultBox.FromValue(Task.FromResult(v == 1 ? ExceptionOrNone.None : new ApplicationException("test error"))));
Assert.False(sut.IsSuccess);
}
[Fact]
public async Task VerifyWithResultBox4()
{
var sut = await ResultBox.FromValue(2)
.Verify(v => ResultBox.FromValue(v == 1 ? ExceptionOrNone.None : new ApplicationException("test error"))).ToTask();
Assert.False(sut.IsSuccess);
}
[Fact]
public async Task VerifyWithResultBox5()
{
var sut = await ResultBox.FromValue(1).ToTask()
.Verify(v => ResultBox.FromValue(Task.FromResult(v == 1 ? ExceptionOrNone.None : new ApplicationException("test error"))));
Assert.True(sut.IsSuccess);
}
[Fact]
public async Task VerifyWithResultBox6()
{
var sut = await ResultBox.FromValue(1).ToTask()
.Verify(v => ResultBox.FromValue(v == 1 ? ExceptionOrNone.None : new ApplicationException("test error")));
Assert.True(sut.IsSuccess);
}
[Fact]
public async Task VerifyWithResultBox7()
{
var sut = await ResultBox.FromValue(2).ToTask()
.Verify(v => ResultBox.FromValue(Task.FromResult(v == 1 ? ExceptionOrNone.None : new ApplicationException("test error"))));
Assert.False(sut.IsSuccess);
}
[Fact]
public async Task VerifyWithResultBox8()
{
var sut = await ResultBox.FromValue(2).ToTask()
.Verify(v => ResultBox.FromValue(v == 1 ? ExceptionOrNone.None : new ApplicationException("test error")));
Assert.False(sut.IsSuccess);
}
[Fact]
public async Task VerifyWithResultBox9()
{
var sut = await ResultBox.FromValue(1).ToTask()
.Verify(v => ResultBox.FromException<ExceptionOrNone>(new ApplicationException("test error")));
Assert.False(sut.IsSuccess);
}
[Fact]
public async Task VerifyWithResultBox10()
{
var sut = await ResultBox.FromValue(1)
.Verify(v => ResultBox.FromException<ExceptionOrNone>(new ApplicationException("test error"))).ToTask();
Assert.False(sut.IsSuccess);
}
}
Loading

0 comments on commit 1822b8a

Please sign in to comment.