Esempio n. 1
0
 public IEnumerable <Chord> Chords(string searchTerm)
 {
     searchTerm = searchTerm.Trim();
     this.logger.LogInformation($"APP LOGGING ===> Chords with searchTerm: {searchTerm}");
     //return this.Chords().Where(chord => chord.Description.Contains(searchTerm, StringComparison.InvariantCultureIgnoreCase));
     return(NoteSequenceUtilities.SearchDescriptions(this.chordData.Chords, searchTerm));
 }
Esempio n. 2
0
        public void WhenSearchDescriptionIsCalledForChordsWithVariantSpelling_ThenAllMatchingChordsAreReturned()
        {
            // Arrange
            var searchTerm           = "eenth";
            var expectedDescriptions = new[]
            {
                "13th",
                "Minor 13th",
                "Major 13th",
                "Minor + Major 13th",
                "7th+13th",
                "Minor 7th+13th",
                "Major 7th+13th",
                "Minor + Major 7th+13th",
                "9th Flattened 13th"
            };

            // Act
            var results = NoteSequenceUtilities.SearchDescriptions(this.chordData.Chords, searchTerm);

            // Assert
            Assert.IsNotNull(results);
            var resultsArray = results as Chord[] ?? results.ToArray();

            Assert.AreEqual(9, resultsArray.Length);
            Assert.AreEqual(0, expectedDescriptions.Except(resultsArray.Select(r => r.Description)).Count());
        }
Esempio n. 3
0
        public void WhenSearchDescriptionIsCalledForChordsWithSingleTerm_ThenAllMatchingChordsAreReturned()
        {
            // Arrange
            var searchTerm = "maj";

            // Act
            var results = NoteSequenceUtilities.SearchDescriptions(this.chordData.Chords, searchTerm);

            // Assert
            Assert.IsNotNull(results);
            var resultsArray = results as Chord[] ?? results.ToArray();

            Assert.AreEqual(16, resultsArray.Length);
            Assert.IsTrue(resultsArray.All(result => result.Description.Contains(searchTerm, StringComparison.InvariantCultureIgnoreCase)));
        }
Esempio n. 4
0
        public void WhenSearchDescriptionIsCalledForChordsWithVariantSpellingMultipleMatchingHits_ThenAllMatchingChordsAreReturned()
        {
            // Arrange
            var searchTerm           = "even";
            var expectedDescriptions = new[]
            {
                "7th",
                "Major 7th",
                "Minor 7th",
                "Diminished 7th",
                "7th Flattened 5th",
                "7th Sharpened 5th",
                "7th Flattened 9th",
                "7th Sharpened 9th",
                "Major 7th+9th",
                "11th",
                "Augmented 11th",
                "Minor + Major 7th",
                "Minor 11th",
                "Major 11th",
                "Minor + Major 11th",
                "7th+11th",
                "Minor 7th+11th",
                "Major 7th+11th",
                "Minor + Major 7th+11th",
                "7th+13th",
                "Minor 7th+13th",
                "Major 7th+13th",
                "Minor + Major 7th+13th",
                "7th Sharpened 5th Flattened 9th",
                "Minor 7th Flattened 5th",
                "Minor 7th Sharpened 5th",
                "Minor 7th Flattened 9th",
                "7th Suspended 4th",
                "Major 7th Suspended 4th"
            };

            // Act
            var results = NoteSequenceUtilities.SearchDescriptions(this.chordData.Chords, searchTerm);

            // Assert
            Assert.IsNotNull(results);
            var resultsArray = results as Chord[] ?? results.ToArray();

            Assert.AreEqual(29, resultsArray.Length);
            Assert.AreEqual(0, expectedDescriptions.Except(resultsArray.Select(r => r.Description)).Count());
        }
Esempio n. 5
0
        public IEnumerable <ChordInstance> ChordNotes(string root, string searchTerm)
        {
            searchTerm = searchTerm.Trim();
            this.logger.LogInformation($"APP LOGGING ===> ChordNotes with root: {root} and searchTerm: {searchTerm}");
            var chordResults   = NoteSequenceUtilities.SearchDescriptions(this.chordData.Chords, searchTerm);
            var chordArray     = chordResults as Chord[] ?? chordResults.ToArray();
            var chordInstances = new List <ChordInstance>(chordArray.Length);

            foreach (var chord in chordArray)
            {
                var chordInstance = ChordInstance.Create(
                    chord.Description,
                    chord.Notes,
                    (List <string>)NoteSequenceUtilities.GetNotes(this.chordData, root, chord));

                chordInstances.Add(chordInstance);
            }

            return(chordInstances);
        }
Esempio n. 6
0
        public IEnumerable <ScaleInstance> ScaleNotes(string root, string searchTerm)
        {
            searchTerm = searchTerm.Trim();

            this.logger.LogInformation($"APP LOGGING ===> ScaleNotes with root: {root} and searchTerm: {searchTerm}");
            var scaleResults   = NoteSequenceUtilities.SearchDescriptions(this.chordData.Scales, searchTerm);
            var scaleArray     = scaleResults as Scale[] ?? scaleResults.ToArray();
            var scaleInstances = new List <ScaleInstance>(scaleArray.Length);

            foreach (var scale in scaleArray)
            {
                var scaleInstance = ScaleInstance.Create(
                    scale.Description,
                    scale.Notes,
                    (List <string>)NoteSequenceUtilities.GetNotes(this.chordData, root, scale));

                scaleInstances.Add(scaleInstance);
            }

            return(scaleInstances);
        }