public void SwitchEarlySCatchFirst() { List <int> output = new List <int>(); ValueTuple <Stream <int>, StreamSink <int>, StreamSink <int>, CellSink <Stream <int> >, IListener> t = Transaction.Run(() => { StreamSink <int> c1 = Stream.CreateSink <int>(); StreamSink <int> c2 = Stream.CreateSink <int>(); CellSink <Stream <int> > s = Cell.CreateSink(c1.AsStream()); Stream <int> c = s.SwitchEarlyS(); c1.Send(2); c2.Send(12); s.Send(c2); IListener l = c.Listen(output.Add); return(ValueTuple.Create(c, c1, c2, s, l)); }); t.Item2.Send(3); t.Item3.Send(13); Transaction.RunVoid(() => { t.Item2.Send(4); t.Item3.Send(14); t.Item4.Send(t.Item2); }); t.Item2.Send(5); t.Item3.Send(15); t.Item5.Unlisten(); CollectionAssert.AreEqual(new[] { 12, 13, 4, 5 }, output); }