protected void Test_Process_VstEventCollection_SentToReplay(VstEventCollection vstEvents, int NumMssCompatibleEvents)
        {
            MidiHandlerProtectedWrapper midiHandler = Factory_MidiHandler_Basic();

            midiHandler.Process(vstEvents);

            Assert.AreEqual(numDryEventsReceivedByRelay, NumMssCompatibleEvents);
        }
        protected MidiHandlerProtectedWrapper Factory_MidiHandler_Basic()
        {
            MidiHandlerProtectedWrapper midiHandler = new MidiHandlerProtectedWrapper();

            midiHandler.Init(() => this.dryMssEventInputPort,
                             () => this.wetMssEventOutputPort,
                             () => this.hostInfoOutputPort);

            var vstHostMock = new Mock <IVstHost>();

            midiHandler.InitVstHost(vstHostMock.Object);

            return(midiHandler);
        }
        public void ConvertMssEventToVstMidiEvent_NoValidConversion_ReturnsNull()
        {
            MidiHandlerProtectedWrapper midiHandler = Factory_MidiHandler_Basic();

            long sampleTime = 123456;

            MssEvent internalEvent = new MssEvent();

            internalEvent.mssMsg     = new MssMsg(MssMsgType.Generator, 0, 0, 0);
            internalEvent.sampleTime = sampleTime;

            VstMidiEvent convertedEvent = midiHandler.ConvertMssEventToVstMidiEventWrapper(
                internalEvent, sampleTime, this.hostInfoOutputPort.SampleRate);

            Assert.IsNull(convertedEvent);
        }
        //*******************************Helpers*******************************


        //if testMssToMidi is true then this method tests ConvertMssEventToVstMidiEvent. Otherwise this method tests ConvertVstMidiEventToMssEvent
        protected void Test_MsgConversion(MssMsgType msgType, int midiChannel, int midiParam1, int midiParam2, bool testMssToMidi)
        {
            long sampleTimeAtStartOfCycle = 12345;
            int  deltaFrames = 789;

            MidiHandlerProtectedWrapper midiHandler = Factory_MidiHandler_Basic();

            MssEvent mssEvent = new MssEvent();

            if (msgType == MssMsgType.PitchBend)
            {
                mssEvent.mssMsg = new MssMsg(msgType, midiChannel, MssMsgUtil.UNUSED_MSS_MSG_DATA, (midiParam2 << 7) + midiParam1);
            }
            else
            {
                mssEvent.mssMsg = new MssMsg(msgType, midiChannel, midiParam1, midiParam2);
            }
            mssEvent.sampleTime = sampleTimeAtStartOfCycle + deltaFrames;

            byte[]       midiData  = MidiUtil.CreateMidiData(msgType, midiChannel, (byte)midiParam1, (byte)midiParam2);
            VstMidiEvent midiEvent = new VstMidiEvent(deltaFrames, 0, 0, midiData, 0, 0x00);

            if (testMssToMidi == true)
            {
                MssEvent convertedMssEvent = midiHandler.ConvertVstMidiEventToMssEventWrapper(
                    midiEvent, sampleTimeAtStartOfCycle, this.hostInfoOutputPort.SampleRate);
                Assert.AreEqual(mssEvent, convertedMssEvent);
            }
            else
            {
                VstMidiEvent ConvertedMidiEvent = midiHandler.ConvertMssEventToVstMidiEventWrapper(
                    mssEvent, sampleTimeAtStartOfCycle, this.hostInfoOutputPort.SampleRate);
                Assert.AreEqual(midiEvent.Data, ConvertedMidiEvent.Data);
                Assert.AreEqual(midiEvent.DeltaFrames, ConvertedMidiEvent.DeltaFrames);
            }
        }
        protected MidiHandlerProtectedWrapper Factory_MidiHandler_Basic()
        {
            MidiHandlerProtectedWrapper midiHandler = new MidiHandlerProtectedWrapper();
            midiHandler.Init(() => this.dryMssEventInputPort,
                             () => this.wetMssEventOutputPort,
                             () => this.hostInfoOutputPort);

            var vstHostMock = new Mock<IVstHost>();
            midiHandler.InitVstHost(vstHostMock.Object);

            return midiHandler;
        }