private void RemoveNotes_EventsCollection_WithoutPredicate( ContainerType containerType, ICollection <MidiEvent> midiEvents, ICollection <MidiEvent> expectedMidiEvents) { var eventsCollection = new EventsCollection(); eventsCollection.AddRange(midiEvents); var notesCount = eventsCollection.GetNotes().Count(); switch (containerType) { case ContainerType.EventsCollection: { Assert.AreEqual( notesCount, eventsCollection.RemoveNotes(), "Invalid count of removed notes."); 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( notesCount, trackChunk.RemoveNotes(), "Invalid count of removed notes."); 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: { RemoveNotes_TrackChunks_WithoutPredicate( containerType == ContainerType.File, new[] { midiEvents }, new[] { expectedMidiEvents }); } break; } }
private void GetNotes_DetectionSettings_EventsCollection( ContainerType containerType, NoteDetectionSettings settings, ICollection <MidiEvent> midiEvents, ICollection <Note> expectedNotes) { switch (containerType) { case ContainerType.EventsCollection: { var eventsCollection = new EventsCollection(); eventsCollection.AddRange(midiEvents); var notes = eventsCollection.GetNotes(settings); MidiAsserts.AreEqual(expectedNotes, notes, "Notes are invalid."); var timedObjects = eventsCollection.GetObjects(ObjectType.Note, new ObjectDetectionSettings { NoteDetectionSettings = settings }); MidiAsserts.AreEqual(expectedNotes, timedObjects, "Notes are invalid from GetObjects."); } break; case ContainerType.TrackChunk: { var trackChunk = new TrackChunk(midiEvents); var notes = trackChunk.GetNotes(settings); MidiAsserts.AreEqual(expectedNotes, notes, "Notes are invalid."); var timedObjects = trackChunk.GetObjects(ObjectType.Note, new ObjectDetectionSettings { NoteDetectionSettings = settings }); MidiAsserts.AreEqual(expectedNotes, timedObjects, "Notes are invalid from GetObjects."); } break; case ContainerType.TrackChunks: case ContainerType.File: { GetNotes_DetectionSettings_TrackChunks( containerType == ContainerType.File, settings, new[] { midiEvents }, expectedNotes); } break; } }