forked from Cysharp/R3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLiveListTest.cs
52 lines (39 loc) · 1.09 KB
/
LiveListTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace R3.Tests;
public class LiveListTest
{
[Fact]
public void FromEvent()
{
var publisher = new Subject<int>();
var list = publisher.ToLiveList();
list.AssertEqual([]);
publisher.OnNext(10);
list.AssertEqual([10]);
publisher.OnNext(20);
list.AssertEqual([10, 20]);
publisher.OnNext(30);
list.AssertEqual([10, 20, 30]);
list.Dispose();
publisher.OnNext(40);
list.AssertEqual([10, 20, 30]);
}
[Fact]
public void BufferSize()
{
var publisher = new Subject<int>();
var list = publisher.ToLiveList(bufferSize: 5);
publisher.OnNext(10);
publisher.OnNext(20);
publisher.OnNext(30);
publisher.OnNext(40);
publisher.OnNext(50);
list.AssertEqual([10, 20, 30, 40, 50]);
publisher.OnNext(60);
list.AssertEqual([20, 30, 40, 50, 60]);
list[0].Should().Be(20);
list[1].Should().Be(30);
list[2].Should().Be(40);
list[3].Should().Be(50);
list[4].Should().Be(60);
}
}