Files
erri120 3f16e316b0 Add WhereNotNull operator
Using optimized `WhereSelect`, the `WhereNotNull` operator is very
common and many libraries and applications had to DIY implement
this for `System.IObservable<T>`.
2024-08-10 19:19:50 +02:00

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"]);
}
}