コード例 #1
0
        private static IEnumerable <Recorded <Notification <char> > > FromMarbles(string marbles)
        {
            var time       = 0L;
            var syncEvents = false;

            foreach (var character in marbles)
            {
                if (character == ' ')
                {
                    continue;
                }

                if (character == '(')
                {
                    syncEvents = true;
                    continue;
                }

                if (character == ')')
                {
                    syncEvents = false;
                    continue;
                }

                var marbleEvents = character switch
                {
                    '#' => EnumerableEx.Return(ReactiveTest.OnError <char>(time, new Exception("end"))),
                    '|' => EnumerableEx.Return(ReactiveTest.OnCompleted(time, character)),
                    '-' => Enumerable.Empty <Recorded <Notification <char> > >(),
                    _ => EnumerableEx.Return(ReactiveTest.OnNext(time, character)),
                };

                foreach (var marble in marbleEvents)
                {
                    yield return(marble);
                }

                if (syncEvents)
                {
                    continue;
                }

                time += 10;
            }
        }