Beispiel #1
0
        public void ConvertToJsonTest()
        {
            var midiNoteFactory = IMidiNoteOnFactory.Default;
            var midiCcFactory   = IMidiControlChangeFactory.Default;
            var midiPcFactory   = IMidiProgramChangeFactory.Default;

            var articulation = TestDataGenerator.CreateArticulation(
                new List <MidiNoteOn> {
                midiNoteFactory.Create(1, 23)
            },
                new List <MidiControlChange> {
                midiCcFactory.Create(2, 34)
            },
                new List <MidiProgramChange> {
                midiPcFactory.Create(3, 45)
            }
                );

            var entity = TestDataGenerator.CreateKeySwitch(articulation);

            var translator = new KeySwitchToJsonModel();
            var json       = translator.Translate(entity);

            var translator2 = new JsonModelToKeySwitch();
            var cmp         = translator2.Translate(json);

            Assert.AreEqual(entity, cmp);

            Console.WriteLine(json);
        }
 public void ConvertToEntityWithoutTest(string jsonText)
 {
     var translator = new JsonModelToKeySwitch();
     var entity     = translator.Translate(new PlainText(jsonText));
 }
 public void ConvertToEntityTest()
 {
     const string jsonText   = "{\"id\":\"d374e5e0-3b95-4f68-be4c-746dd8077a53\",\"author\":\"Author\",\"description\":\"Description\",\"created\":\"2020-09-16T07:04:52.657Z\",\"last_updated\":\"2020-09-16T07:04:52.657Z\",\"developer_name\":\"DeveloperName\",\"product_name\":\"ProductName\",\"instrument_name\":\"E.Guitar\",\"articulations\":[{\"name\":\"Power Chord\",\"type\":1,\"group\":0,\"color\":0,\"midi_message\":{\"note_on\":[{\"status\":144,\"channel\":0,\"data1\":1,\"data2\":23}],\"control_change\":[{\"status\":176,\"channel\":0,\"data1\":2,\"data2\":34}],\"program_change\":[{\"status\":192,\"channel\":3,\"data1\":45,\"data2\":0}]}}]}";
     var          translator = new JsonModelToKeySwitch();
     var          entity     = translator.Translate(new PlainText(jsonText));
 }