Beispiel #1
0
        public void InputDataSplitsDataAtDuration(
            [Values(0.01, 0.5, 0.751)] double splitDuration
            )
        {
            IDictionary <string, object> config = new Dictionary <string, object>();
            const int nSamples = 1000;
            var       srate    = new Measurement(nSamples, "Hz");

            var data = Enumerable.Range(0, nSamples).Select(i => new Measurement(i, "V")).ToList();

            IInputData inData = new InputData(data, srate, DateTimeOffset.Now);

            var duration = new TimeSpan((long)Math.Ceiling(splitDuration * TimeSpan.TicksPerSecond));
            var result   = inData.SplitData(duration);

            //rounds samples up for duration
            int numSamples = (int)Math.Ceiling(duration.TotalSeconds * (double)inData.SampleRate.QuantityInBaseUnit);

            IEnumerable firstData = Enumerable.Range(0, numSamples).Select(i => inData.Data[i]).ToList();
            IEnumerable restData  = Enumerable.Range(numSamples, inData.Data.Count - numSamples).Select(i => inData.Data[i]).ToList();


            Assert.AreEqual(firstData, result.Head.Data);
            Assert.AreEqual(restData, result.Rest.Data);
        }
Beispiel #2
0
        public void InputDataSplitDataReturnsEntireDataForOverDuration()
        {
            IDictionary <string, object> config = new Dictionary <string, object>();
            var srate = new Measurement(1000, "Hz");

            IInputData inData = new InputData(this.Data, srate, DateTimeOffset.Now).DataWithStreamConfiguration(streamFake, new Dictionary <string, object>());

            var duration = new TimeSpan(1, 0, 0); //1 hr
            var result   = inData.SplitData(duration);

            Assert.AreEqual(inData.Data, result.Head.Data);
            Assert.AreEqual(0, result.Rest.Duration.TotalSeconds);
        }