示例#1
0
        private void RemoveChords_DetectionSettings_EventsCollection_WithoutPredicate(
            ContainerType containerType,
            ChordDetectionSettings settings,
            ICollection <MidiEvent> midiEvents,
            ICollection <MidiEvent> expectedMidiEvents)
        {
            var eventsCollection = new EventsCollection();

            eventsCollection.AddRange(midiEvents);

            var chordsCount = eventsCollection.GetChords(settings).Count;

            switch (containerType)
            {
            case ContainerType.EventsCollection:
            {
                Assert.AreEqual(
                    chordsCount,
                    eventsCollection.RemoveChords(settings),
                    "Invalid count of removed chords.");

                var expectedEventsCollection = new EventsCollection();
                expectedEventsCollection.AddRange(expectedMidiEvents);

                MidiAsserts.AreEqual(expectedEventsCollection, eventsCollection, true, "Events are invalid.");
                Assert.IsTrue(
                    eventsCollection.All(e => midiEvents.Any(ee => object.ReferenceEquals(e, ee))),
                    "There are new events references.");
            }
            break;

            case ContainerType.TrackChunk:
            {
                var trackChunk = new TrackChunk(eventsCollection);

                Assert.AreEqual(
                    chordsCount,
                    trackChunk.RemoveChords(settings),
                    "Invalid count of removed chords.");

                var expectedTrackChunk = new TrackChunk(expectedMidiEvents);
                MidiAsserts.AreEqual(expectedTrackChunk, trackChunk, true, "Events are invalid.");
                Assert.IsTrue(
                    trackChunk.Events.All(e => midiEvents.Any(ee => object.ReferenceEquals(e, ee))),
                    "There are new events references.");
            }
            break;

            case ContainerType.TrackChunks:
            case ContainerType.File:
            {
                RemoveChords_DetectionSettings_TrackChunks_WithoutPredicate(
                    containerType == ContainerType.File,
                    settings,
                    new[] { midiEvents },
                    new[] { expectedMidiEvents });
            }
            break;
            }
        }