private void RemoveTimedEvents_EventsCollection_WithPredicate( ContainerType containerType, ICollection <MidiEvent> midiEvents, Predicate <TimedEvent> match, ICollection <MidiEvent> expectedMidiEvents, int expectedRemovedCount) { var eventsCollection = new EventsCollection(); eventsCollection.AddRange(midiEvents); switch (containerType) { case ContainerType.EventsCollection: { Assert.AreEqual( expectedRemovedCount, eventsCollection.RemoveTimedEvents(match), "Invalid count of removed timed events."); 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( expectedRemovedCount, trackChunk.RemoveTimedEvents(match), "Invalid count of removed timed events."); 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: { RemoveTimedEvents_TrackChunks_WithPredicate( containerType == ContainerType.File, new[] { midiEvents }, match, new[] { expectedMidiEvents }, expectedRemovedCount); } break; } }