public void TestAddNamedTrackCopyWithOwnEnd() { var manualMidi = new MidiEventCollection(1, 200); var noteEvent = new NoteOnEvent(0, 1, 1, 1, 1); const string trackName = "name"; var trackNameEvent = new TextEvent(trackName, MetaEventType.SequenceTrackName, 0); var endTrackEvent = new MetaEvent(MetaEventType.EndTrack, 0, 90); var track = manualMidi.AddTrack(); track.Add(trackNameEvent); track.Add(noteEvent); track.Add(noteEvent.OffEvent); track.Add(endTrackEvent); var extensionMidi = new MidiEventCollection(1, 200); var events = new MidiEvent[] { noteEvent, noteEvent.OffEvent, endTrackEvent }; extensionMidi.AddNamedTrackCopy(trackName, events); MidiAssert.Equal(manualMidi, extensionMidi); // Assert they aren't the same objects var manualTrack = manualMidi[0]; var extensionTrack = extensionMidi[0]; for (var e = 0; e < manualTrack.Count; e++) { Assert.That(extensionTrack[e], Is.Not.SameAs(manualTrack[e])); } // Verify the NoteOnEvent.OffEvent link Assert.AreEqual(extensionMidi[0][2], ((NoteOnEvent)extensionMidi[0][1]).OffEvent); }