Beispiel #1
0
        public void CheckFileEventsReceiving()
        {
            var filesToTest = TestFilesProvider.GetValidFiles(
                f => f.GetTrackChunks().Count() == 1,
                f => (TimeSpan)f.GetDuration <MetricTimeSpan>() < TimeSpan.FromSeconds(30))
                              .Take(5)
                              .ToArray();

            for (var i = 0; i < filesToTest.Length; i++)
            {
                var file     = filesToTest[i];
                var tempoMap = file.GetTempoMap();

                var eventsToSend = new List <EventToSend>();
                var currentTime  = TimeSpan.Zero;

                foreach (var timedEvent in file.GetTimedEvents().Where(e => !(e.Event is MetaEvent)))
                {
                    var time        = (TimeSpan)timedEvent.TimeAs <MetricTimeSpan>(tempoMap);
                    var eventToSend = new EventToSend(timedEvent.Event, time - currentTime);
                    currentTime = time;
                    eventsToSend.Add(eventToSend);
                }

                SendReceiveUtilities.CheckEventsReceiving(eventsToSend);
            }
        }
        public void CheckFileEventsReceivingOnConnectedDevices()
        {
            var filesToTestCount = 5;
            var maxFileDuration  = TimeSpan.FromSeconds(10);

            var filesToTest = TestFilesProvider.GetValidFiles(
                f => f.GetTrackChunks().Count() == 1,
                f => (TimeSpan)f.GetDuration <MetricTimeSpan>() < maxFileDuration)
                              .OrderByDescending(f => f.GetDuration <MetricTimeSpan>())
                              .Take(filesToTestCount)
                              .ToArray();

            Debug.Assert(filesToTest.Length == filesToTestCount, "Not enough files for test.");

            for (var i = 0; i < filesToTest.Length; i++)
            {
                var file     = filesToTest[i];
                var tempoMap = file.GetTempoMap();

                var eventsToSend = new List <EventToSend>();
                var currentTime  = TimeSpan.Zero;

                foreach (var timedEvent in file.GetTimedEvents().Where(e => !(e.Event is MetaEvent)))
                {
                    var time        = (TimeSpan)timedEvent.TimeAs <MetricTimeSpan>(tempoMap);
                    var eventToSend = new EventToSend(timedEvent.Event, time - currentTime);
                    currentTime = time;

                    if (eventToSend.Event is SysExEvent)
                    {
                        continue;
                    }

                    eventsToSend.Add(eventToSend);
                }

                CheckEventsReceiving(eventsToSend);
            }
        }
        public void CheckFileEventsReceivingOnConnectedDevices()
        {
            var filesToTest = TestFilesProvider.GetValidFiles(
                f => f.GetTrackChunks().Count() == 1,
                f =>
            {
                var tempoMap = f.GetTempoMap();
                return((TimeSpan)f.GetTimedEvents().Last().TimeAs <MetricTimeSpan>(tempoMap) < TimeSpan.FromSeconds(30));
            })
                              .Take(5)
                              .ToArray();

            for (var i = 0; i < filesToTest.Length; i++)
            {
                var file     = filesToTest[i];
                var tempoMap = file.GetTempoMap();

                var eventsToSend = new List <EventToSend>();
                var currentTime  = TimeSpan.Zero;

                foreach (var timedEvent in file.GetTimedEvents().Where(e => !(e.Event is MetaEvent)))
                {
                    var time        = (TimeSpan)timedEvent.TimeAs <MetricTimeSpan>(tempoMap);
                    var eventToSend = new EventToSend(timedEvent.Event, time - currentTime);
                    currentTime = time;

                    if (eventToSend.Event is SysExEvent)
                    {
                        continue;
                    }

                    eventsToSend.Add(eventToSend);
                }

                CheckEventsReceiving(eventsToSend);
            }
        }