private void ProcessChords_DetectionSettings_EventsCollection_WithoutPredicate( ContainerType containerType, ChordDetectionSettings settings, ICollection <MidiEvent> midiEvents, Action <Chord> action, ICollection <MidiEvent> expectedMidiEvents) { var chordsCount = midiEvents.GetChords(settings).Count; switch (containerType) { case ContainerType.EventsCollection: { var eventsCollection = new EventsCollection(); eventsCollection.AddRange(midiEvents); Assert.AreEqual( chordsCount, eventsCollection.ProcessChords(action, settings), "Invalid count of processed 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(midiEvents); Assert.AreEqual( chordsCount, trackChunk.ProcessChords(action, settings), "Invalid count of processed 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: { ProcessChords_DetectionSettings_TrackChunks_WithoutPredicate( containerType == ContainerType.File, settings, new[] { midiEvents }, action, new[] { expectedMidiEvents }); } break; } }
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; } }