mirror of
https://github.com/Cysharp/R3.git
synced 2026-10-29 07:16:37 +08:00
Using optimized `WhereSelect`, the `WhereNotNull` operator is very common and many libraries and applications had to DIY implement this for `System.IObservable<T>`.
25 lines
493 B
C#
25 lines
493 B
C#
namespace R3.Tests.OperatorTests;
|
|
|
|
public class WhereNotNullTest(ITestOutputHelper output)
|
|
{
|
|
[Fact]
|
|
public void WhereNotNull()
|
|
{
|
|
var p = new Subject<string?>();
|
|
|
|
using var list = p.WhereNotNull().ToLiveList();
|
|
|
|
p.OnNext(null);
|
|
list.AssertEqual([]);
|
|
|
|
p.OnNext("foo");
|
|
list.AssertEqual(["foo"]);
|
|
|
|
p.OnNext(null);
|
|
list.AssertEqual(["foo"]);
|
|
|
|
p.OnNext("bar");
|
|
list.AssertEqual(["foo", "bar"]);
|
|
}
|
|
}
|