Exemplo n.º 1
0
        public void AddTest()
        {
            var repository   = new LiteDbKeySwitchRepository(new MemoryStream());
            var articulation = TestDataGenerator.CreateArticulation(
                new List <MidiNoteOn>()
            {
                new MidiNoteOn(new MidiStatus(MidiStatusHelper.NoteOn), new MidiNoteNumber(1), new MidiVelocity(100))
            },
                new List <MidiControlChange>(),
                new List <MidiProgramChange>()
                );
            var record = TestDataGenerator.CreateKeySwitch(articulation);

            var result = repository.Save(record);

            Assert.AreEqual(1, result.Inserted);

            var seq = repository.Find(record.ProductName);
            var cmp = seq.First();

            Assert.AreEqual(record, cmp);

            seq = repository.Find(record.DeveloperName);
            cmp = seq.First();
            Assert.AreEqual(record, cmp);

            seq = repository.Find(record.ProductName);
            cmp = seq.First();
            Assert.AreEqual(record, cmp);

            seq = repository.Find(record.DeveloperName, record.ProductName, record.InstrumentName);
            cmp = seq.First();
            Assert.AreEqual(record, cmp);
        }
Exemplo n.º 2
0
        private static IReadOnlyCollection <KeySwitch> Query(CommandOption option)
        {
            using var repository = new LiteDbKeySwitchRepository(option.DatabasePath);
            var developerName = new DeveloperName(option.Developer);
            var productName   = new ProductName(option.Product);

            return(repository.Find(developerName, productName));
        }
        public void ImportTest()
        {
            var jsonText = "[{\"id\":\"419db555-cc1d-405c-8b28-281ded630a45\",\"author\":\"Author\",\"description\":\"Description\",\"created\":\"2020-09-15T16:21:11.354Z\",\"last_updated\":\"2020-09-15T16:21:11.354Z\",\"developer_name\":\"DeveloperName\",\"product_name\":\"ProductName\",\"instrument_name\":\"E.Guitar\",\"articulation\":[{\"articulation_name\":\"Power Chord\",\"articulation_type\":1,\"articulation_group\":0,\"articulation_color\":0,\"midi_message\":{\"note_on\":[],\"control_change\":[],\"program_change\":[]}}]}]";

            var dbRepository = new LiteDbKeySwitchRepository(new MemoryStream());
            var inputData    = new ImportingTextRequest(jsonText);
            var translator   = new JsonModelListToKeySwitchList();
            var interactor   = new ImportingJsonInteractor(
                dbRepository,
                translator, new IImportingTextPresenter.Console()
                );

            interactor.Execute(inputData);

            var entities = dbRepository.Find(new DeveloperName("DeveloperName"));
            var cmp      = translator.Translate(inputData.JsonText);

            var keySwitches = entities.ToList();
            var cmpList     = cmp.ToList();

            Assert.AreEqual(keySwitches.Count(), cmpList.Count());
            Assert.AreEqual(keySwitches.First(), cmpList.First());
        }