Example #1
0
        public void run_graph_process_data_jump_back_restore_state()
        {
            var g      = new Graph();
            var node   = new BasicTestNode(g);
            var source = new SourceNode(g);
            var sink   = new SinkNode(g);

            g.Connect(source.OutputPorts[0], node.InputPorts[0]);
            g.Connect(node.OutputPorts[0], sink.InputPorts[0]);

            Assert.IsTrue(g.Run());
            Assert.AreEqual(node.Factor, 0);

            source.SendData(source.Samplerate);
            System.Threading.Thread.Sleep(1000);

            var state  = g.SaveState();
            var factor = node.Factor;
            var stamp  = ((DataInputPort)sink.InputPorts[0]).Queue.BeginTime;

            source.SendData(source.Samplerate);
            System.Threading.Thread.Sleep(1000);

            Assert.AreNotEqual(node.Factor, factor);

            g.LoadState(state);

            Assert.AreEqual(node.Factor, factor);
            Assert.AreEqual(stamp, ((DataInputPort)sink.InputPorts[0]).Queue.BeginTime);

            g.Stop();
        }
Example #2
0
        public void save_state_change_and_restore()
        {
            var g = new Graph();
            var n = new BasicTestNode(g);

            var before = n.Factor;

            var state = n.SaveState();

            n.Change();
            state.Load();

            var after = n.Factor;

            Assert.AreEqual(before, after);
        }