Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 2c17dcc

Browse files
committed
Test whether adding before subscribing works
1 parent 2fefc54 commit 2c17dcc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/TrackingCollectionTests/TrackingCollectionTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,4 +1957,24 @@ public void RemovingWithNoObservableSetThrows()
19571957
ITrackingCollection<Thing> col = new TrackingCollection<Thing>();
19581958
Assert.Throws<InvalidOperationException>(() => col.RemoveItem(new Thing()));
19591959
}
1960+
1961+
[Test]
1962+
public async void AddingBeforeSubscribingWorks()
1963+
{
1964+
ITrackingCollection<Thing> col = new TrackingCollection<Thing>(Observable.Empty<Thing>());
1965+
ReplaySubject<Thing> done = new ReplaySubject<Thing>();
1966+
col.AddItem(GetThing(1));
1967+
col.AddItem(GetThing(2));
1968+
var count = 0;
1969+
done.OnNext(null);
1970+
col.Subscribe(t =>
1971+
{
1972+
done.OnNext(t);
1973+
if (++count == 2)
1974+
done.OnCompleted();
1975+
}, () => {});
1976+
1977+
await Observable.Timeout(done, TimeSpan.FromMilliseconds(500));
1978+
Assert.AreEqual(2, col.Count);
1979+
}
19601980
}

0 commit comments

Comments
 (0)