An AnonymousNode subclass that takes in multiple ints and returns a single one.
Inheritance: AnonymousNode
Ejemplo n.º 1
0
        public void RenderTicksProcessesLongGraph()
        {
            AnonIntNode graph = Enumerable.Range(0, 100).Aggregate(
                new AnonIntNode((inputs, tick) => tick),
                (node, _) => new AnonIntNode(i => i[0] + 1, node)
                );

            Assert.Equal(Enumerable.Range(100, 20).ToArray(), RenderTicksAnonIntNodes(new PipelineDriver(), graph).Take(20).ToEnumerable().ToArray());
        }
Ejemplo n.º 2
0
        public void RenderTicksProcessesDiamondGraph()
        {
            AnonIntNode start = new AnonIntNode((_, tick) => tick);
            AnonIntNode graph = new AnonIntNode(inputs => inputs[0] + inputs[1],
                                                new AnonIntNode(inputs => inputs[0], start),
                                                new AnonIntNode(inputs => inputs[0], start)
                                                );

            var tokenSource = new CancellationTokenSource();
            var frames      = RenderTicksAnonIntNodes(new PipelineDriver(), graph, 0, token: tokenSource.Token).Take(5).ToEnumerable();

            Assert.Equal(new[] { 0, 2, 4, 6, 8 }, frames.ToArray());
        }
Ejemplo n.º 3
0
 // Render a graph of anonymous int-returning nodes
 IObservable <int> RenderTicksAnonIntNodes(PipelineDriver driver, AnonIntNode startNode, int tick = 0, CancellationToken?token = null)
 {
     return(driver.RenderTicks(new[] { startNode }, token: token).Select(dic => dic[startNode.Outputs[0]].Size.Width));
 }