Exemplo n.º 1
0
        ISignalStack ISignalHandler.GetValuesAt(int position, ISignalStack collectorStack, uint loopLength, bool recursive)
        {
            //create an empty collectorStack if not available
            if (collectorStack == null)
            {
                collectorStack = new WaveStack();
            }                                                                                 //[TO-DO] !! Is there some way to define default collector class elsewhere/pass it through parameters?
            //			!! Perhaps some way to remove this conditional?

            //if this wave corresponds to target position, add its value to the stack
            if ((this as ISignalHandler).HasValuesAt(position, loopLength))
            {
                collectorStack.AddValue(_waveValue);
            }

            //return a reference to used collection stack
            return(collectorStack);
        }
        public void UTSignalFragmentGetValuesAt4()
        {
            SignalFragment testItem1 = new SignalFragment(0,
                                                          new List <ISignalContent> {
                new Wave(1, 0),
                new Wave(1, 2),
                new SignalFragment(0, new List <ISignalContent> {
                    new Wave(1, 2)
                })
            }
                                                          );


            ISignalStack testCollector = new WaveStack();

            (testItem1 as ISignalHandler).GetValuesAt(0, collectorStack: testCollector);
            Assert.AreEqual(1, testCollector.Value);

            testCollector = new WaveStack();
            (testItem1 as ISignalHandler).GetValuesAt(2, collectorStack: testCollector);
            Assert.AreEqual(2, testCollector.Value);
        }