public void TestAccum() { var ea = new EventSink <int>(); var @out = new List <int>(); Behavior <int> sum = ea.Accum <int>(100, (a, s) => a + s); Listener l = sum.Value().Listen(x => { @out.Add(x); }); ea.Send(5); ea.Send(7); ea.Send(1); ea.Send(2); ea.Send(3); l.Unlisten(); CollectionAssert.AreEqual(new[] { 100, 105, 112, 113, 115, 118 }, @out); }
public void TestAccum() { var ea = new EventSink<int>(); var @out = new List<int>(); Behavior<int> sum = ea.Accum<int>(100, (a, s) => a + s); Listener l = sum.Value().Listen(x => { @out.Add(x); }); ea.Send(5); ea.Send(7); ea.Send(1); ea.Send(2); ea.Send(3); l.Unlisten(); CollectionAssert.AreEqual(new[] { 100, 105, 112, 113, 115, 118 }, @out); }