Test_sketch adapted from Midi Example you'll need Midi Arduino Library installed which is available at
https://github.com/FortySevenEffects/arduino_midi_library/releases/latest
Arduino MocoLufa Builds Mega2560 and Uno and Leonardo
I havent personally tested leonardo or uno, but it should work
for boards with 2 usb ports native & programming try USBMIDI library https://www.arduino.cc/en/Reference/MIDIUSB https://github.com/arduino-libraries/MIDIUSB