public void SplitEmptyObservables1() { var lastValues = new List <int>(); bool isCompleted = false; // var lastValues=new List<KeyValuePair<int, int>>(); IPushSubject <KeyValuePair <int, int> > src = new PushSubject <KeyValuePair <int, int> >(); var resS = src.Group(i => i.Key, iS => iS.Map(i => i.Value).Last()); resS.Subscribe(i => lastValues.Add(i), () => isCompleted = true); src.Complete(); CollectionAssert.AreEquivalent(new int[0], lastValues); Assert.IsTrue(isCompleted); }
public void SplitObservables2() { var lastValues = new List <int>(); bool isCompleted = false; // var lastValues=new List<KeyValuePair<int, int>>(); IPushSubject <KeyValuePair <int, int> > src = new PushSubject <KeyValuePair <int, int> >(); var resS = src.Group(i => i.Key, iS => iS.Scan((acc, val) => acc + val.Value, 0)); resS.Subscribe(i => lastValues.Add(i), () => isCompleted = true); src.PushValue(new KeyValuePair <int, int>(1, 1)); src.Complete(); CollectionAssert.AreEquivalent(new[] { 1 }, lastValues); Assert.IsTrue(isCompleted); }
public void SplitObservables() { var lastValues = new List <int>(); bool isCompleted = false; // var lastValues=new List<KeyValuePair<int, int>>(); IPushSubject <KeyValuePair <int, int> > src = new PushSubject <KeyValuePair <int, int> >(); var resS = src.Group(i => i.Key, iS => iS.Last().Map(i => i.Value)); resS.Subscribe(i => lastValues.Add(i), () => isCompleted = true); src.PushValue(new KeyValuePair <int, int>(1, 1)); src.PushValue(new KeyValuePair <int, int>(1, 2)); src.PushValue(new KeyValuePair <int, int>(2, 3)); src.PushValue(new KeyValuePair <int, int>(2, 4)); src.PushValue(new KeyValuePair <int, int>(1, 5)); src.PushValue(new KeyValuePair <int, int>(1, 6)); src.Complete(); CollectionAssert.AreEquivalent(new[] { 6, 4 }, lastValues); Assert.IsTrue(isCompleted); }