Пример #1
0
        public void FindSingleNoteMatches_NoSingleNotesInProfile_DoesNotMatchAnything_Test()
        {
            // Arrange
            var profile = new MidiMappingProfile
            {
                Mappings = new List <MidiMappingRecord>
                {
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(new[] { Pitch.C1, Pitch.E1, Pitch.G1 })
                    },
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(new[] { Pitch.A1, Pitch.C2, Pitch.E2 })
                    },
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(new[] { Pitch.G1, Pitch.B1, Pitch.D2, Pitch.FSharp2 })
                    },
                }
            };

            var matcher = new MidiMappingMatcher(profile);

            // Assert
            Assert.AreEqual(0, matcher.FindSingleNoteMatches(Pitch.C1).Length);
            Assert.AreEqual(0, matcher.FindSingleNoteMatches(Pitch.E1).Length);
            Assert.AreEqual(0, matcher.FindSingleNoteMatches(Pitch.G1).Length);
            Assert.AreEqual(0, matcher.FindSingleNoteMatches(Pitch.FSharp2).Length);
        }
Пример #2
0
        public void FindSingleNoteMatches_OctavesDoNotMatch_DoesNotMatchAnything_Test()
        {
            // Arrange
            var profile = new MidiMappingProfile
            {
                Mappings = new List <MidiMappingRecord>
                {
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(Pitch.C1)
                    },
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(Pitch.A2)
                    },
                }
            };

            var matcher = new MidiMappingMatcher(profile);

            // Assert
            Assert.AreEqual(0, matcher.FindSingleNoteMatches(Pitch.C0).Length);
            Assert.AreEqual(0, matcher.FindSingleNoteMatches(Pitch.C2).Length);
            Assert.AreEqual(0, matcher.FindSingleNoteMatches(Pitch.A0).Length);
            Assert.AreEqual(0, matcher.FindSingleNoteMatches(Pitch.A1).Length);
            Assert.AreEqual(0, matcher.FindSingleNoteMatches(Pitch.A3).Length);
        }
Пример #3
0
        public void FindSingleNoteMatches_SingleMatchingRecord_OneMatchFound_Test()
        {
            // Arrange
            var profile = new MidiMappingProfile
            {
                Mappings = new List <MidiMappingRecord>
                {
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(Pitch.C1)
                    },
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(Pitch.A2)
                    },
                }
            };

            var matcher = new MidiMappingMatcher(profile);

            // Act
            var matchesFound = matcher.FindSingleNoteMatches(Pitch.A2);

            // Assert
            Assert.AreEqual(1, matchesFound.Length);
            Assert.AreEqual(Pitch.A2, matchesFound[0].Trigger.Pitches[0]);
        }
Пример #4
0
        public void FindSingleNoteMatches_EmptyMappingProfile_DoesNotMatchAnything_Test()
        {
            // Arrange
            var matcher = new MidiMappingMatcher(emptyMappingProfile);

            // Assert
            foreach (var pitch in Enum.GetValues(typeof(Pitch)).Cast <Pitch>())
            {
                Assert.AreEqual(0, matcher.FindSingleNoteMatches(pitch).Length);
            }
        }
Пример #5
0
        public void FindSingleNoteMatches_DuplicateRecords_AllMatchesFound_Test()
        {
            // Arrange
            var profile = new MidiMappingProfile
            {
                Mappings = new List <MidiMappingRecord>
                {
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(Pitch.C1)
                    },
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(Pitch.A2)
                    },
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(Pitch.C1)
                    },
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(Pitch.C1)
                    },
                    new MidiMappingRecord {
                        Trigger = new MidiInputTrigger(new[] { Pitch.C1, Pitch.E1, Pitch.G1 })
                    },
                }
            };

            var matcher = new MidiMappingMatcher(profile);

            // Act
            var matchesFound = matcher.FindSingleNoteMatches(Pitch.C1);

            // Assert
            Assert.AreEqual(3, matchesFound.Length);
            foreach (var match in matchesFound)
            {
                Assert.AreEqual(Pitch.C1, match.Trigger.Pitches[0]);
            }
        }