예제 #1
0
        public void TestCollect()
        {
            var         ea   = new EventSink <int>();
            var         @out = new List <int>();
            Event <int> sum  = ea.Collect(
                (int)100,
                //(a,s) => new Tuple2(a+s, a+s)
                (a, s) => new Tuple <int, int>(a + s, a + s));
            Listener l = sum.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[] { 105, 112, 113, 115, 118 }, @out);
        }
예제 #2
0
 public void TestCollect()
 {
   var ea = new EventSink<int>();
   var @out = new List<int>();
   Event<int> sum = ea.Collect(
     (int)100,
     //(a,s) => new Tuple2(a+s, a+s)
     (a, s) => new Tuple<int, int>(a + s, a + s));
   Listener l = sum.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[] { 105, 112, 113, 115, 118 }, @out);
 }