mirror of
https://github.com/Cysharp/R3.git
synced 2026-10-23 02:00:54 +08:00
33 lines
927 B
C#
33 lines
927 B
C#
namespace R3.Tests.FactoryTests;
|
|
|
|
public class ThrowTest
|
|
{
|
|
// throw test
|
|
[Fact]
|
|
public void Throw()
|
|
{
|
|
{
|
|
var e = new Exception();
|
|
using var list = Observable.Throw<int>(e).ToLiveList();
|
|
list.AssertEqual([]);
|
|
list.Result.IsFailure.Should().BeTrue();
|
|
list.Result.Exception.Should().Be(e);
|
|
}
|
|
{
|
|
var fakeTime = new FakeTimeProvider();
|
|
|
|
var e = new Exception();
|
|
using var list = Observable.Throw<int>(e, TimeSpan.FromSeconds(5), fakeTime).ToLiveList();
|
|
|
|
fakeTime.Advance(TimeSpan.FromSeconds(4));
|
|
list.AssertEqual([]);
|
|
list.AssertIsNotCompleted();
|
|
|
|
fakeTime.Advance(TimeSpan.FromSeconds(1));
|
|
list.AssertEqual([]);
|
|
list.Result.IsFailure.Should().BeTrue();
|
|
list.Result.Exception.Should().Be(e);
|
|
}
|
|
}
|
|
}
|