コード例 #1
0
ファイル: CommonTests.cs プロジェクト: stjordanis/sodium
        public void TestOperationalSplit()
        {
            StreamSink <List <string> > a = Stream.CreateSink <List <string> >();
            Stream <string>             b = Operational.Split <string, List <string> >(a);
            List <string> @out            = new List <string>();
            IListener     l = b.Listen(@out.Add);

            a.Send(new List <string> {
                "a", "b"
            });
            l.Unlisten();
            CollectionAssert.AreEqual(new[] { "a", "b" }, @out);
        }
コード例 #2
0
        public void TestOperationalSplit()
        {
            StreamSink <List <string> > a = new StreamSink <List <string> >();
            Stream <string>             b = Operational.Split <string, List <string> >(a);
            List <string> @out            = new List <string>();

            using (b.Listen(@out.Add))
            {
                a.Send(new List <string> {
                    "a", "b"
                });
            }
            CollectionAssert.AreEqual(new[] { "a", "b" }, @out);
        }
コード例 #3
0
        public void Test_Split_TestCase()
        {
            Tuple <Stream <IReadOnlyList <char> >, ILookup <int, Action> > st = MkStream(new[]
            {
                Tuple.Create <int, IReadOnlyList <char> >(0, new[] { 'a', 'b' }),
                Tuple.Create <int, IReadOnlyList <char> >(1, new[] { 'c' }),
                Tuple.Create <int, IReadOnlyList <char> >(1, new[] { 'd', 'e' })
            },
                                                                                         (x, y) => x.Concat(y).ToArray());
            Stream <IReadOnlyList <char> > s  = st.Item1;
            ILookup <int, Action>          sf = st.Item2;
            List <char> @out = RunSimulation <char>(Operational.Split <char, IReadOnlyList <char> >(s).Listen, new[] { sf });

            CollectionAssert.AreEqual(new[] { 'a', 'b', 'c', 'd', 'e' }, @out);
        }